File tree 3 files changed +15
-8
lines changed
3 files changed +15
-8
lines changed Original file line number Diff line number Diff line change @@ -58,7 +58,7 @@ Cfg::Cfg() : currentSession(-1)
58
58
options.insert (option (" auto_login" , " no" ));
59
59
options.insert (option (" current_theme" , " default" ));
60
60
options.insert (option (" lockfile" , " /var/run/slim.lock" ));
61
- options.insert (option (" logfile" , " /var/log/slim.log " ));
61
+ options.insert (option (" logfile" , " /dev/stderr " ));
62
62
options.insert (option (" authfile" , " /var/run/slim.auth" ));
63
63
options.insert (option (" shutdown_msg" , " The system is halting..." ));
64
64
options.insert (option (" reboot_msg" , " The system is rebooting..." ));
Original file line number Diff line number Diff line change 1
1
#include " log.h"
2
+ #include < cstring>
2
3
#include < iostream>
3
4
4
5
bool LogUnit::openLog (const char * filename)
@@ -9,8 +10,12 @@ bool LogUnit::openLog(const char * filename)
9
10
<< endl;
10
11
logFile.close ();
11
12
}
12
- logFile.open (filename, ios_base::app);
13
13
14
+ // cerr is the default
15
+ if (strcmp (filename, " /dev/stderr" ) == 0 )
16
+ return true ;
17
+
18
+ logFile.open (filename, ios_base::app);
14
19
return !(logFile.fail ());
15
20
}
16
21
Original file line number Diff line number Diff line change 9
9
#endif
10
10
#include " const.h"
11
11
#include < fstream>
12
+ #include < iostream>
12
13
13
14
using namespace std ;
14
15
15
16
static class LogUnit
16
17
{
17
18
ofstream logFile;
19
+ inline ostream & getStream () { return logFile.is_open () ? logFile : cerr; }
18
20
19
21
public:
20
22
bool openLog (const char * filename);
@@ -24,22 +26,22 @@ static class LogUnit
24
26
25
27
template <typename Type> LogUnit & operator <<(const Type & text)
26
28
{
27
- logFile << text;
28
- logFile .flush ();
29
+ getStream () << text;
30
+ getStream () .flush ();
29
31
return *this ;
30
32
}
31
33
32
34
LogUnit & operator <<(ostream & (*fp)(ostream &))
33
35
{
34
- logFile << fp;
35
- logFile .flush ();
36
+ getStream () << fp;
37
+ getStream () .flush ();
36
38
return *this ;
37
39
}
38
40
39
41
LogUnit & operator <<(ios_base & (*fp)(ios_base &))
40
42
{
41
- logFile << fp;
42
- logFile .flush ();
43
+ getStream () << fp;
44
+ getStream () .flush ();
43
45
return *this ;
44
46
}
45
47
} logStream;
You can’t perform that action at this time.
0 commit comments