liberror - Message Printing


liberror screen shot

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

liberror 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.

liberror with assertion macros

liberror's output of assertions


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.

small program using liberror

Let's compile and test this.

progress messages with liberror

You can reach the library on the command line via --msg- options. E.g. you could want to hide the banner.

error library's banner hidden

Or hide all progress messages.

progress message hidden

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).

setting quiet level of error library

You can select the level of progress messages (if the programmer ordered them hierarchically as above (using dots)).

simple method of setting message hierarchy

For normal errors, the program continues normally incrementing an error counter that can be checked at exit:

error counts are maintained

For fatal errors, an internal callback terminates the programm with exit(EXIT_FAILURE) immediately (callbacks can be added by the user, too).

fatal messages terminate programm immediately


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. :-)

messages of liberror are in color


Download

Content

Index

January 17th, 2023
Comments? Suggestions? Corrections? You can drop me a line.
zpentrabvagiktu@theiling.de
Schwerpunktpraxis
Datenschutz