Next: , Previous: DI.h, Up: Interface


4.5 L.h: support for printf style logging

These routines are used to provide logging functions. Messages can be divided into classes and separately enabled and disabled.

— Macro: void L (args...)

Used to log a message in a similar way to printf.

Defaults to a using fprintf on stderr.

— Macro: void LG (bool guard, args...)
— Macro: void LH (function handler, args...)
— Macro: void LP (text param, args...)
— Macro: void LGP (bool guard, text param, args...)
— Macro: void LHP (function handler, text param, args...)
— Macro: void LGHP (bool guard, function handler, text param, args...)

And all of the special functions.

The macros such as ‘L’ depend on the GNU CC variable number of arguments to macros extension. If you wish to compile your code on other systems you might wish to use the following variations on ‘L’, etc.

— Macro: void VL ((args...))
— Macro: void VLG ((bool guard, args...))
— Macro: void VLH ((function handler, args...))
— Macro: void VLP ((text param, args...))
— Macro: void VLGP ((bool guard, text param, args...))
— Macro: void VLHP ((function handler, text param, args...))
— Macro: void VLGHP ((bool guard, function handler, text param, args...))

Each of these macros calls the corresponding function from the previous group, i.e. by default ‘VLG’ is the same as a call to ‘LG’. If you define ‘WITHOUT_NANA’ all these macros are translated to ‘/* empty */’.

Thus you can have nana under GCC whilst the code is still portable to other compilers. However debugging information will not be available on other platforms.

Note: the argument list is surrounded by two sets of brackets. For example:

             VL(("haze in darwin = %d\n", 3.4));
— Macro: void L_LEVEL

Used to enable and disable logging independently of guard expressions.

2
Always print message
1
Print message only if the guard expression is true.
0
Never print any messages.

Defaults to 1.

— Macro: text L_DEFAULT_HANDLER

The default handler for printing which is simply the name of the logging function or macro.

Defaults to fprintf

— Macro: bool L_DEFAULT_GUARD

The default guard condition for logging.

Defaults to TRUE.

— Macro: text L_DEFAULT_PARAMS

The default parameter passed off to the logging function or macro.

Defaults to stderr

— Macro: void L_SHOW_TIME

If defined then display the time in front of each message.

— Macro: char* L_SHOW_TIME_FORMAT

A format string for the time stamp in the log. By default it prints the time out in seconds.

— Macro: value L_SHOW_TIME_NOW

The name of a function that returns the time for the time stamp. This defaults to the ‘now’ function from ‘now.h’.