dist_tools/
mg_log.pro
includes main-level program MG_LOG
is a procedural interface to the logging framework.
MG_LOG
is a convenience routine so that the MGffLogger
object does not
need to be explicitly stored by the application using the logging. If more
than one logger is required, then named loggers can be used using the NAME
keyword.
The error levels are: critical (level 1), error (level 2), warning (level 3), informational (level 4), debug (level 5). Only log messages with a level less than or equal to the current logger level are actually recorded. So if a logger is set to level 3 (warnings), then log messages with levels 1 (critical), 2 (error), or 3 (warning) would be displayed, but log messages with levels 4 (informational) or 5 (debug) would be ignored.
Named subloggers can be created using the NAME
keyword. These subloggers
should be used for individual applications or functional areas of an
application.
For example, the following starts the logging framework and creates a
logger object with name "mg_example" returned via the LOGGER
keyword:
mg_log, name='mg_example', logger=logger
my_application.log
, do:
logger->setProperty, level=3, filename='my_application.log'
mg_log, 'A problem occurred!', /warning, name='mg_example'
mg_log, name='mg_example/gui', logger=gui_logger
gui_logger
was set to "Informational" with:
gui_logger->setProperty, level=4
Examples
Try the main-level program at the end of this file for a longer example. To run it, do:
IDL> .run mg_log
Routines
top mg_log
mg_log [, msg] [, arg1] [, arg2] [, arg3] [, arg4] [, arg5] [, arg6] [, name=string] [, /debug] [, /informational] [, /warning] [, /error] [, /critical] [, /last_error] [, logger=object] [, /quit] [, _extra=keywords]
Messages are logged via this routine. Also, the LOGGER
keyword returns the
logging object which is used to configure the logging.
Parameters
- msg in optional type=string
message to log, if present; is interpreted as a format string when additional parameters are present
- arg1 in optional type=string
optional argument to be substituted into
msg
format string- arg2 in optional type=string
optional argument to be substituted into
msg
format string- arg3 in optional type=string
optional argument to be substituted into
msg
format string- arg4 in optional type=string
optional argument to be substituted into
msg
format string- arg5 in optional type=string
optional argument to be substituted into
msg
format string- arg6 in optional type=string
optional argument to be substituted into
msg
format string
Keywords
- name in optional type=string
path to logger to send message to
- debug in optional type=boolean
set to specify the message as debug
- informational in optional type=boolean
set to specify the message as informational
- warning in optional type=boolean
set to specify the message as a warning
- error in optional type=boolean
set to specify the message as an error
- critical in optional type=boolean
set to specify the message as critical
- last_error in optional type=boolean
set to place a stack trace for the last error in the log; placed after the logging of any normal message in this call
- logger out optional type=object
MGffLogger
object- quit in optional type=boolean
set to quit logging; will log an normal message in this call before quitting
- _extra in optional type=keywords
keywords to
MGffLogger::setProperty
to configure the logger
File attributes
Modification date: | Wed May 14 15:07:14 2014 |
Lines: | 70 |
Docformat: | rst rst |
Contact me if you have enhancement requests or bug fixes.