My new C++ logging library

It has been a while since I’ve made my last post. I always prefer to write code instead of updating my blog, but once or twice a year I feel like the blog is looking abandoned and then I react with an update of the current project status.

Although I’ve done several updates to the Cassini engine, this post is to talk about my new lightweight C++ library: cpplogging.

The Cassini engine uses it’s own logging implementation, which is very simple and lightweight, but so embedded in the code that it isn’t reusable in other projects. It also lacks of some basic functionality a logging API should always have, like formatters and support for log rotations.

When I started a new project a few months ago, I tried to use the Cassini’s logging subsystem, but I’ve found it hard to extract from the core engine, and no external logging library (at least the ones I’ve tried), seamed to fulfill my requirements for a logging library: simple, fast, portable, flexible, and ready to use (no compilation needed). Even the few ones that were close to my requirements, seemed outdated or abandoned.

So I’ve decided to start a new library called cpplogging, you can take a look at http://cpplogging.sourceforge.net/ .

The library isn’t officially released yet, but you can test it  by checking the mercurial repository, or wait a few days until I release the version 1.0.

The general features of the library are:

  • Header only C++ library (no compilation needed).
  • Highly portable (it works in Windows and most Linux/Unix based systems).
  • Really fast (although it’s written in C++, the file handlers and string operations use pure CRT calls to improve performance).
  • Support for log rotations (rolling).
  • Automatic platform detection (changing the end-of-line mode according to the running OS).
  • Thread safe
  • Full Unicode support.
  • Very flexible and customizable (you can write your own handlers -syslog, eventlog, etc…-, and formatters).
  • BSD license (very liberal).

I’ll be porting the Cassini’s logging subsystem to this API soon, and then I’ll release the first cpplogging beta version on SourceForge.

Stay tuned!!