new logging facility


Thread Starter

Mario de Sousa

Hello all,

I have just uploaded a centralised logging facility for the plc. The idea is for every module to use this interface in order to get a consistent log.

The following two command line options
allows for setting the debug level and the loging file.
Default logging file is currently linuxplc.log, and default
debuging level = 0 (i.e. no messages)

The interface is defined in log.h

Three logging functions are available:
plc_log_trcmsg(int min_debug_level, const char *format, ...);
plc_log_wrnmsg(int min_debug_level, const char *format, ...);
plc_log_errmsg(int min_debug_level, const char *format, ...);

The first parameter defines the minimum debugging level that has to be set for the message to be logged. If the current debuging level is lower than the value given, then the message is ignored.

The format parameter (and variable number of following parameters) should be used the same way as the printf(const char * format, ...)

I was thinking on using the three functions as follows:

The trcmsg (trace messages) should be used mainly for debugging messages, such as:
"configured pid function block with P=xx, I=xx, D=xx"

The wrnmsg (warning messages) should be issued
when an error has been detected, but in which the
default values will nevertheless probably work OK.
for ex:
"Error parsing pid function block configuration. Skipping block..."

The errmsg (error message) should be issued when
an error occurs that will probably require fixing
before the plc can continue executing.
for ex:
"Cannot connect to the plc."

I think we should have a discussion and come down with clearer guidelines of when to issue what messages, and at what debugging level.

I'm sure other people on the list are better at writing documentation and of thinking what kind of error could occur.



Mario J. R. de Sousa [email protected]

LinuxPLC mailing list
[email protected]