You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I do not know if it is the right way to do it though.
Now i can use boost log like c++ glog.
It is easy to use boost log to write to both console and disk file with logrotation.
The log filename is like this: foo_20240924_220112.711990_CST.log
log messages are like these:
2024-09-24 22:01:25.084288 CST [debug ] main.cpp:11: This is a debug message.
2024-09-24 22:01:25.084423 CST [info ] main.cpp:12: This is an info message.
2024-09-24 22:01:25.084539 CST [warning] main.cpp:13: This is a warning message.
2024-09-24 22:01:25.084628 CST [error ] main.cpp:14: This is an error message.
2024-09-24 22:01:25.085912 CST [fatal ] main.cpp:15: This is a fatal message.
2024-09-24 22:01:25.086041 CST [trace ] main.cpp:10: This is a trace message.
$ cat main.cpp
#include "log.h"
#include <string>
int main() {
const std::string log_dir = "logs"; // get executable directory
const std::string name = "foo";
init_logging(log_dir, name);
for (;;) { // test rotation
LOG(trace) << "This is a trace message.";
LOG(debug) << "This is a debug message.";
LOG(info) << "This is an info message.";
LOG(warning) << "This is a warning message.";
LOG(error) << "This is an error message.";
LOG(fatal) << "This is a fatal message.";
}
return 0;
}
$
The text was updated successfully, but these errors were encountered:
Hi Andrey,
Yes, i finally got some progress on that and started to know your work of this log library a bit more.
I mostly write single thread code. I will use localtime_r for sure.
Thanks!
Hi, i finally get it done by making an additional call to localtime to get the timezone.
The format
%Z
does not yet work here:I do not know if it is the right way to do it though.
Now i can use boost log like c++ glog.
It is easy to use boost log to write to both console and disk file with logrotation.
The log filename is like this:
foo_20240924_220112.711990_CST.log
log messages are like these:
The text was updated successfully, but these errors were encountered: