liberror - Message Printing
This is a library for C and C++ that solves the allegedly simply task of printing messages. Thus, it is essentially a feature-rich substitute for fprintf(stderr,...).
Features include colours via ANSI mark-up, multiple error streams, report files, automatic error number assignment, filtering by number, subsystems and groups, buffering with manual filtering and re-issuing, callbacks, error counters, time stamping, and message styles.
The library was mainly developed for Unix, but is regularly used and tested under Windos, too (with MSVC). For compilation, you still need a Unix account, since some files are generated for Windos under Unix.
There is also a command line tool ‘eprintf’, that implements a shell interface to the library, so you can easily have nicely coloured error messages from shell scripts now.
Read the reference manual.
See some screenshots.
Download the library.
Command Line Tool |
※ |
Small Demo 1 |
※ |
The macro return0_if_fail_pii is generated with the Erwin tool 'assert.pl'. Those macros automatically use libError for assertion printing if available.
Small Demo 2 |
※ |
A test program that reads the first integer from each text file on the command line and prints the sum of those.
Let's compile and test this.
You can reach the library on the command line via --msg- options. E.g. you could want to hide the banner.
Or hide all progress messages.
Or select a quiet level hiding several types of messages (the message types are internally ordered by importance: banner, progress, note, info, warning, error, internal error, fatal error, assertion failure).
You can select the level of progress messages (if the programmer ordered them hierarchically as above (using dots)).
For normal errors, the program continues normally incrementing an error counter that can be checked at exit:
For fatal errors, an internal callback terminates the programm with exit(EXIT_FAILURE) immediately (callbacks can be added by the user, too).
Colour Messages |
※ |
This shows the (rather messy) output of a small test program testing a few features of the library. The main purpose of this screenshot is to show that messages are in colour. :-)
Download |
※ |