I want to create a Logger class which will act as std::cout.
I want to use it this way:
#include "utils/logger.h"
int main(void)
{
utils::logger << "Hello world";
return 0;
}
Ideally this class will forward all logs to syslog. And syslog levels will be available through helpers like utils::error or utils::critical.
I have found some interesting resources:
I know that this question seems to be already posted but I cannot make the links between all the responses.
- I know the
Loggerclass will have to inherit fromstd::ostreamand / orstd::streambuf. - How to use it directly (ie not instantiate any object in the
main) ? I was thinking to do it globally in autils/logger.ccfile... - How to create the helpers ? I heard that macros are bad in C++
If someone have some useful links, hints and tips or awesome library to share it would be very nice.
Aucun commentaire:
Enregistrer un commentaire