GitHub - lcn2/dbg: debug, warning and error reporting facility (original) (raw)
TL;DR Try dbg
TL;DR Compile and test dbg
TL;DR Install dbg
If you wish to install to another directory prefix, say to /usr instead of the default /usr/local, you can override it by specifying the PREFIX variable:
sudo make PREFIX=/usr install
TL;DR Uninstall dbg
If you wish to uninstall the programs, library and man pages, you can do so like:
If you specified a different PREFIX when installing you'll have to specify that PREFIX. For instance if you installed to /usr:
sudo make PREFIX=/usr uninstall
dbg - info, debug, warning, error and usage message facility
When linked into your program, the dbg facility provides a way to write informative messages, debug messages, warning messages, fatal (and non-fatal) error messages and usage messages to a stream such asstderr, an open file or a buffer of a fixed size.
The dbg facility consists of function calls with argument checking, as well as attempting to do reasonable things when given NULL pointers, bogus values, or when stderr is NULL.
For modern compilers, dbg facility function calls that use a printf-like format strings are checked for format / parameter mismatches. A type mismatch between a format string and types of arguments will result in a compiler warning message.
The dbg facility function calls are easy to add to your C code. There are several ways to control them including the ability to silence message types, and in the case of debug messages, turn on increasing levels of verbosity.
Set up
For more information and an example see the dbg API section.
If you do not wish to install the library:
- Compile
dbg.cto producedbg.o. - Add
#include "dbg.h"to the C source files that you wish to use one or more of thedbgfunctions in. - Set
verbosity_levelto some verbosity level such asDBG_LOW(1) orDBG_MED(3) (seedbg.hfor other levels). - Compile your source file(s) and link in
dbg.o.
Installing the library:
First, compile the library:
Next, install the library (as root or via sudo):
If you wish to change the PREFIX, say to /usr instead of /usr/local, you can do so like:
as root or via sudo.
Then, set up the code kind of like above, but with these changes:
- Add
#include <dbg.h>to the C source files that you wish to use one or more of thedbgfunctions in. - Set the
verbosity_levelto some verbosity level such asDBG_LOW(1) orDBG_MED(3) (seedbg.hfor other levels and the example further below). - Compile your source file(s) and link in
libdbg.a(e.g. pass to the compiler-ldbg).
Uninstalling
If you're tired of bugs :-) you can uninstall the programs, library and man pages like:
as either root or via sudo.
If you installed with a different PREFIX make sure to specify that. For instance if you used PREFIX=/usr do instead:
make PREFIX=/usr uninstall
as either root or via sudo.
The dbg API
For an overview of all the functions, how to control output, general notes and other information, please see the man pages. You can render them like:
man ./man/man3/dbg.3 man ./man/man3/msg.3 man ./man/man3/printf_usage.3 man ./man/man3/warn.3 man ./man/man3/werr.3 man ./man/man3/err.3 man ./man/man3/warn_or_err.3
An example program making use of some of the functions is dbg_example.c. In the man page dbg.3 it shows you how to compile it and it tells you the expected output as well as why that output is expected.
Reporting Security Issues
To report a security issue, please visit "Reporting Security Issues".