I have a lot of small projects, over 100 repos on GitHub. Most of them are simple prototypes, and after some time I started to think about some unification, so I spend less time on typical tasks. These tasks include documentation, logging, building, etc. For logging, I found a very nice library called log.c. Unfortunately, the project is dead, and the author does not accept new PR. I needed some of them, such as C++ support. I could find another library but that one was appealing by its simplicity, so I made a fork. Long story short, after several iterations, the changes became so significant that I detached the fork from the initial repo and now it is a standalone project called microlog (https://github.com/an-dr/microlog). I’ve decided to share it so it can be useful for somebody else, and here are the reasons why you might be interested.
- It is as simple as the original project + supports CMake and Meson.
- You can disable some features, and they will not be compiled.
- By the way, features
- Color
- Timestamps
- Callbacks for extra logging destinations, e.g. files or other interfaces (ROS message, display, other library, whatever you want)
- Custom prefix in which you can add any dynamic information that will be added to each message (e.g. microseconds, ticks, device status, etc.)
- Emojis and more!
In the default configuration, it looks like this:
…but in can be very minimalistic
… or feature-rich:
It is MIT so you can use it freely. If you have any ideas or proposals, you are welcome to make a PR!
Sources: https://github.com/an-dr/microlog