vendredi 28 juillet 2017

c++11 syslog wrapper with logobject/repository functionality

I want to add logging to a project with clients - server.

This post http://ift.tt/2vPeFDl comments gave me the idea to use syslog.

I will using rsyslog. It is for embedded linux system so I need the logging to be light an fast. I find that some of the good loggers (log4xxx, g3log, spdlog) just offer to much for what i want.

requirements:

  • only unix, no need for cross platform
  • lightweight as possible for the requirements I need.
  • named loggers (different objects of the same type, need to know which object the log is from)
  • logging levels set for different loggers (different objects of the same type can have a different level)
  • changing the logging level at run time, I need to able to activate debug logging without rebooting/recompiling (so i think a repository kind of log4xxx style is required? i know this is not as lightweight as possible but i dont want to recompile and flash every node just for turning debugging on)
  • conditional logging (if it is not the right level dont even make the syslog call, i read Can syslog Performance Be Improved? so i will avoid the call if i know i dont have to make it)
  • the syslog call may never block the application, but i dont want to drop the message, is this possible to do in rsyslog itself? I think this might be harder to achieve.. (functionality like g3log asynchronous logging)

Basicly im looking for a simple syslog c++11 wrapper with some object/repository features.

First rule of logging: dont roll ur own, it is harder then it looks.

  • I found http://ift.tt/2vPzQVF but it is seems outdated and no longer maintained
  • Redirect C++ std::clog to syslog on Unix gave me some good ideas but i cant change the log level at runtime and I read that streams are slow so maybe I want to avoid them?
  • http://ift.tt/2vPpMMo this also seems interesting to improve performance
  • c++ logging mentioned above but like I said they offer A LOT and I dont need most it.

Anybody know/have/started an implementation in c++11 that would fill my requirements? Or am I stuck rolling my own from scratch?

Aucun commentaire:

Enregistrer un commentaire