wiki:S3/S3Log

Version 2 (modified by redsin, 11 years ago) ( diff )

--

S3Log

Purpose

S3Log is a simple global logging facility for Sahana Eden.

Logger

The logger is called like:

current.log.error("Something went wrong", value="Example")

Which gives a log entry like:

2014-02-16 11:58:41 S3LOG ERROR: Something went wrong: Example

The logger functions correspond to the severity level of the message:

  • current.log.critical() (highest)
  • current.log.error()
  • current.log.warning()
  • current.log.info()
  • current.log.debug() (lowest)

The call signature of all logger functions is identical with the example above.

Configuration

The logger can be configured in models/000_config:

# Configure the log level ("DEBUG", "INFO", "WARNING", "ERROR" or "CRITICAL"), None = turn off logging
#settings.log.level = None
# Uncomment to write log messages to the console (sys.stderr)
#settings.log.console = True
# Configure a log file (file name)
#settings.log.logfile = None
# Uncomment to get detailed caller information
#settings.log.caller_info = True

Log Level

settings.log.level = "DEBUG"

determines the minimum severity level at which messages will be logged.

Severity levels:

  • CRITICAL (highest)
  • ERROR
  • WARNING
  • INFO
  • DEBUG (lowest)
  • None turns all logging off.

Console

settings.log.console = True 

enables logging to the system error console (sys.stderr). False disables console logging.

Log File

settings.log.logfile = "/var/log/eden.log"

enables logging to the specified file. The logger rotates 3 log files with a maximum size of 1MB: /var/log/eden.log, /var/log/eden.log.1 and /var/log/eden.log.2 None disables logging to file.

Caller Info

With

settings.log.caller_info = True

the log messages will include information about the origin of the log message (file name, line number, function name):

2014-02-16 11:58:23 (applications/eden/modules/s3/s3rest.py 477 __init__) ERROR: Something went wrong: Example
Note: See TracWiki for help on using the wiki.