badaix / aixlog Goto Github PK
View Code? Open in Web Editor NEWHeader-only C++ logging library
License: MIT License
Header-only C++ logging library
License: MIT License
Hi, I use 4 threads and sometimes is output mixed and logs inarticulate. Is exist any good practis how to use it is this situation?
Hello, thanks for your header only logger. I've found it very nice so far.
I do like to compile with -Wall when using gcc, and I get these warnings apparently from using internally linked functions.
Would you consider adding something like: https://gist.github.com/cinnaboot/80cc12ffa6095c8db325be631fc1bb1f to supress the warnings?
I got the macro from this thread https://cboard.cprogramming.com/cplusplus-programming/118695-help-remove-warning-x-function-defined-but-not-used.html that also suggests inlining to get around it.
Is there some way for reading and setting the std::ios_base::flags
for LOG(...)
?
It would be useful e.g. for temporary setting scientific format (std::scientific
).
[1/3] /usr/bin/c++ -I/usr/ports/devel/aixlog/work/aixlog-1.3.0/include -O2 -pipe -fno-omit-frame-pointer -fstack-protector-strong -fno-strict-aliasing -fno-omit-frame-pointer -O2 -pipe -fno-omit-frame-pointer -fstack-protector-strong -fno-strict-aliasing -fno-omit-frame-pointer -std=c++11 -MD -MT CMakeFiles/aixlog_example.dir/aixlog_example.cpp.o -MF CMakeFiles/aixlog_example.dir/aixlog_example.cpp.o.d -o CMakeFiles/aixlog_example.dir/aixlog_example.cpp.o -c /usr/ports/devel/aixlog/work/aixlog-1.3.0/aixlog_example.cpp
FAILED: CMakeFiles/aixlog_example.dir/aixlog_example.cpp.o
/usr/bin/c++ -I/usr/ports/devel/aixlog/work/aixlog-1.3.0/include -O2 -pipe -fno-omit-frame-pointer -fstack-protector-strong -fno-strict-aliasing -fno-omit-frame-pointer -O2 -pipe -fno-omit-frame-pointer -fstack-protector-strong -fno-strict-aliasing -fno-omit-frame-pointer -std=c++11 -MD -MT CMakeFiles/aixlog_example.dir/aixlog_example.cpp.o -MF CMakeFiles/aixlog_example.dir/aixlog_example.cpp.o.d -o CMakeFiles/aixlog_example.dir/aixlog_example.cpp.o -c /usr/ports/devel/aixlog/work/aixlog-1.3.0/aixlog_example.cpp
In file included from /usr/ports/devel/aixlog/work/aixlog-1.3.0/aixlog_example.cpp:15:
/usr/ports/devel/aixlog/work/aixlog-1.3.0/include/aixlog.hpp:531:22: error: no matching constructor for initialization of 'std::thread::id' (aka 'std::__1::__thread_id')
Log() noexcept : last_id_(-1), last_buffer_(nullptr)
^ ~~
/usr/include/c++/v1/__threading_support:416:28: note: candidate constructor (the implicit copy constructor) not viable: no known conversion from 'int' to 'const std::__1::__thread_id' for 1st argument
class _LIBCPP_TEMPLATE_VIS __thread_id
^
/usr/include/c++/v1/__threading_support:416:28: note: candidate constructor (the implicit move constructor) not viable: no known conversion from 'int' to 'std::__1::__thread_id' for 1st argument
/usr/include/c++/v1/__threading_support:465:5: note: candidate constructor not viable: no known conversion from 'int' to 'std::__1::__libcpp_thread_id' (aka 'pthread *') for 1st argument
__thread_id(__libcpp_thread_id __id) : __id_(__id) {}
^
/usr/include/c++/v1/__threading_support:425:5: note: candidate constructor not viable: requires 0 arguments, but 1 was provided
__thread_id() _NOEXCEPT : __id_(0) {}
^
1 error generated.
OS: FreeBSD 12.1
clang-9
Hello,
I find this library quite usefull, but i've just found a bug.
When calling multiple times LOG, latest entry is not logged. As well as when called only once, nothing in log file is created. For example:
LOG(WARNING) << "Warning";
LOG(INFO) << "Information";
Only "Warning" gets outputed.
Furthermore, when calling two times same severity of logging, example:
LOG(WARNING) << "Warning";
LOG(WARNING) << "Warning";
Nothing is logged, until you change severity.
`
int i[2] = { 0,1 };
string t[2] = { R"(E:\product\qqm\cv_pro\log\t1.log)",R"(E:\product\qqm\cv_pro\log\t2.log)" };
thread t1(&xxxx, i[0], t[0].c_str());
thread t2(&xxxx, i[1], t[1].c_str());
t1.join();
t2.join();
system("pause");
`
i want to use it in thread, as this code
i want log every thread with a single log file ,
can aixlog do it?
this 1.4 version do not work well , create two log files, but only ont have the log info
Hello,
Just to let you know, your code can't compil under Visual Studio 2017 due to a compilation bug:
error C2216: 'explicit' can't be used with 'virtual' for the line 287.
It is a bug in visual studio as explicit should be usable with virtual, but visual studio has this bug from the 2013 version, so I don't expect a fix soon.
Great job anyway, just one more question that is not in the documentation: is your logging library thread-safe?
I'm using aixlog in a project with a big amount of files and functions useful to perform various calculations which will be recycled by multiple binaries. Not all these binaries might need to log their output, but when I do not use any initialisation the result is still printed to cout, except in a more garbled form (with no spaces). Is it possible to make it the default to not print anything unless an initialisation has been performed?
You'd better replace
OutputDebugString with OutputDebugStringA
RegisterEventSource with RegisterEventSourceA
ReportEvent with ReportEventA
You should call the "A" version of these functions explicitly, since you pass ansi char strings to them.
Otherwise 64-bit windows builds are broken. OutputDebugString is defined to OutputDebugStringW on 64-bit platform and compiler can not convert const char* to required LPCWSTR.
aixlog.hpp(847,1): error C2664: 'void OutputDebugStringA(LPCSTR)': cannot convert argument 1 from 'const _Elem *' to 'LPCSTR'
...
aixlog.hpp(1008,1): error C2664: 'HANDLE RegisterEventSourceA(LPCSTR,LPCSTR)': cannot convert argument 2 from 'const _Elem *' to 'LPCSTR'
...
aixlog.hpp(1038,1): error C2664: 'BOOL ReportEventA(HANDLE,WORD,WORD,DWORD,PSID,WORD,DWORD,LPCSTR *,LPVOID)': cannot convert argument 8 from 'const wchar_t **' to 'LPCSTR *'
After Explicitly typecasting to LPCSTR *
, the build goes through.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.