File tree Expand file tree Collapse file tree 3 files changed +16
-8
lines changed
Expand file tree Collapse file tree 3 files changed +16
-8
lines changed Original file line number Diff line number Diff line change @@ -17,6 +17,7 @@ Interface Interface::instance;
1717Interface::Interface () : versionStr(std::string(Main::version))
1818{
1919 IO::Log::setEnabled (false );
20+ IO::Log::setTimestamp (false );
2021 needsUpdate = false ;
2122 eventParam = nullptr ;
2223}
Original file line number Diff line number Diff line change @@ -7,28 +7,34 @@ using namespace IO;
77namespace
88{
99static bool enabled = true ;
10+ static bool timestamp = true ;
1011static Log::LogFunc logFunc = [](std::string const &s)
1112{
1213 puts (s.c_str ());
1314};
1415
1516}
1617
17- LogRecord::LogRecord () : content(" [vizzu] [YYYY-mm-ddTHH:MM:SSZ] " )
18+ LogRecord::LogRecord () : content(" [vizzu] " )
1819{
19- std::time_t now;
20- std::time (&now);
21- std::strftime (content.data () + 9 ,
22- 21 ,
23- " %Y-%m-%dT%H:%M:%SZ" ,
24- std::gmtime (&now));
25- content[9 + 20 ] = ' ]' ;
20+ if (timestamp) {
21+ content += " [YYYY-mm-ddTHH:MM:SSZ] " ;
22+ std::time_t now;
23+ std::time (&now);
24+ std::strftime (content.data () + 9 ,
25+ 21 ,
26+ " %Y-%m-%dT%H:%M:%SZ" ,
27+ std::gmtime (&now));
28+ content[9 + 20 ] = ' ]' ;
29+ }
2630}
2731
2832void Log::set (Log::LogFunc f) { logFunc = std::move (f); }
2933
3034void Log::setEnabled (bool value) { enabled = value; }
3135
36+ void Log::setTimestamp (bool value) { timestamp = value; }
37+
3238void Log::print (const std::string &msg)
3339{
3440 if (logFunc) logFunc (msg);
Original file line number Diff line number Diff line change @@ -17,6 +17,7 @@ class Log
1717 typedef std::function<void (const std::string &)> LogFunc;
1818 static void set (LogFunc f);
1919 static void setEnabled (bool );
20+ static void setTimestamp (bool );
2021
2122private:
2223 static void print (const std::string &msg);
You can’t perform that action at this time.
0 commit comments