Development logging is a powerful tool any real time or embedded programmer employs. Do you use development logging from your code?.. If yes, cpp_trace library may help.
I started to write this library since I need it at every my project. And with every project I needed to make some logging component which allows to filter, buffer, route to output device and bla-bla-bla.
Every time I faced the same problems: time consuming filtering, delayed text formatting and filter id managing. These are the reasons to design new effective solution.
Main cpp_trace design decisions are:
1. Use any declared type for filter ids (do you know C++ type lists?..).
This means you are have no limits for ids such as number of bits for a mask or range boundary for enum.
2. Use compile time filtering if possible (partial template specification allows to eliminate unused code).
This means you can use trace instructions at any place with any frequency in code - it has no impact on production performance.
3. Comply with STL streams.
This means you can follow standard at first. Second, you can override operator<< and control every parameter independently (to make buffering of unprocessed parameters and delay text formatting).
I use the library for a year now. It is just an alpha version which has no run-time filtering and delayed text formatting so far. I found it extremely useful for a unit testing since you can identify a filter with class type you are implementing. Then at unit test just list classes you want to debug and get the log from it! From another point, if you like common filter identification by constant values or enumerations: just use BOOST wrappers for constants that converts constant value into a type.
If you are interested, read more at cpp_trace wiki and enjoy.
No comments:
Post a Comment