Cyclone3 Skin

Log messages at runtime

From Cyclone3 Wiki

For critical module errors, you can set the value of $tom::ERR before calling return undef in your module. This message will log into the default pub.err.log of the domain. For instance, calling

$tom::ERR="Could not fetch data from database!";
return undef;

in your 010-modulename.0.smdl will add the following to the err log:

[SMDL::010_modulename] Could not fetch data from database!

If you need to log any information or debug messages, there is a convenient logging function of Cyclone3 that does it for you (don't forget that you can change the log level for a certain servicetype or even set it up differently for a specific module in your servicetype):

main::_log();

The function can take either a single string parameter

main::_log("DB request returned".$rows."rows");

or multiple parameters that help you customize what and where exactly the function should write

main::_log(errormessage, [errorregime], [engine/logname], [loglevel]);

where

  • errormessage

the actual message to log

  • errorregime [0-4]
    • 0 notice - log to current level
    • 1 error - log to current level, must be logged
    • 2 notice - log to current level, must be logged
    • 3 notice - log to root level, must be logged
    • 4 error - log to root level, must be logged
  • engine, or logname

will be used for the log filename (i.e. 2010-03-11.logname.log)

  • loglevel

0-local, 1-global, 2-master

Examples

  • standard way of logging a notice message in current scope, logging into the default engine log. For instance, in publisher engine, this message will be logged into yyyy-mm-dd.pub.log. Won't log, if $TOM::DEBUG_log_file in [local.conf] is not specified or set to 0.
main::_log('this is a local scope notice message');
  • Same as standard log message, with the addition, that it will be also logged into yyyy-mm-dd.pub.err.log.
main::_log('this is a local scope error message', 1);
  • Log a critical notice to current scope
main::_log('this is a critical local scope notice message', 2);
  • Log a critical notice to root level
main::_log('this is a critical global scope notice message', 3);
  • Log a critical error to root level, to my own logfile
main::_log('this is a critical global scope error message', 4, 'mydebug');