logging policy

M

Thread Starter

Mario de Sousa

Hi all,

Here is a first rough draft of a logging policy. Somebody had to do it. I await your comments...


Level 0 - No logging info whatsoever.
Level 1 - Default logging level. To be used by any part of the program to log messages that one would like to see by default.
Level 2..5 - To be used only by module specific code.
Level 6..9 - To be used by the LPLC libraries (smm, synch, conffile, ...)
Level 9 - Maximum logging level.

Trace - Log successful execution of a specific action.
Warning - Something has gone wrong, or unexpected result received, but an alternative/default/fallback action is available and will (note: in the future) be tried. If all alternatives fail, only then log an error
message.
Error - Something is seriously wrong, for which no corrective action is known, and the only solution is to give up on that specific action. Note that the PLC or the module that experienced the error does not necessarily have to stop executing (or crash), but may continue with other actions (e.g. modbus_tcp module cannot connect to a remote host 1 to read point A, but continues to connect to host 2 to get point B).


I don't really like the policy for level 1. Please do come up with alternatives.

Mario.


----------------------------------------------------------------------------
Mario J. R. de Sousa [email protected]
----------------------------------------------------------------------------

_______________________________________________
LinuxPLC mailing list
[email protected]
http://linuxplc.org/mailman/listinfo/linuxplc
 
I've used these, and they've not sucked too bad:

Trace: function start/stop, thread start/stop, etc.
Note: States some fact about a running function or class.
Warning: Something unwanted has occurred, but function worked
Error: A function call cannot complete due to errors
Failure: A necessary operation cannot complete

My 'trace' messages usually are things like entering/leaving functions, finally reaching some part of the code, etc. Normally turned off unless there is trouble.

Notes are to telling about tags/points changing value mostly. Sometimes added to tell about other events of value for reasoning through problems. Also, all my logged events have time in ms, so I can get rough timings. I add notes sometimes just to help get the timings.

Warnings, etc are self-explanatory.

I set these all up in a bitfield, and turn on/off whatever things I want, rather than having a level. I plan on having filtering by module, so I
have source line and filename in the log message. Here you'd probably need some more space-conscious way of denoting where messages come from. Maybe another bit field?

Levels have always been a solution, but never all that satisfying. More sophisticated filtering is always wanted, but performance and size issues get in the way.


_______________________________________________
LinuxPLC mailing list
[email protected]
http://linuxplc.org/mailman/listinfo/linuxplc
 
Top