| 1 | = S3Log = |
| 2 | [[TOC]] |
| 3 | |
| 4 | == Purpose == |
| 5 | |
| 6 | S3Log is a simple global logging facility for Sahana Eden. |
| 7 | |
| 8 | == Logger == |
| 9 | |
| 10 | The logger is called like: |
| 11 | {{{#!python |
| 12 | current.log.error("Something went wrong", value="Example") |
| 13 | }}} |
| 14 | Which gives a log entry like: |
| 15 | {{{ |
| 16 | 2014-02-16 11:58:41 S3LOG ERROR: Something went wrong: Example |
| 17 | }}} |
| 18 | The logger functions correspond to the severity level of the message: |
| 19 | - current.log.critical() (highest) |
| 20 | - current.log.error() |
| 21 | - current.log.warning() |
| 22 | - current.log.info() |
| 23 | - current.log.debug() (lowest) |
| 24 | The call signature of all logger functions is identical with the example above. |
| 25 | |
| 26 | == Configuration == |
| 27 | |
| 28 | The logger can be configured in models/000_config: |
| 29 | {{{#!python |
| 30 | # Configure the log level ("DEBUG", "INFO", "WARNING", "ERROR" or "CRITICAL"), None = turn off logging |
| 31 | #settings.log.level = None |
| 32 | # Uncomment to write log messages to the console (sys.stderr) |
| 33 | #settings.log.console = True |
| 34 | # Configure a log file (file name) |
| 35 | #settings.log.logfile = None |
| 36 | # Uncomment to get detailed caller information |
| 37 | #settings.log.caller_info = True |
| 38 | }}} |
| 39 | |
| 40 | === Log Level === |
| 41 | |
| 42 | {{{#!python |
| 43 | settings.log.level = "DEBUG" |
| 44 | }}} |
| 45 | determines the minimum severity level at which messages will be logged. |
| 46 | |
| 47 | Severity levels: |
| 48 | - CRITICAL (highest) |
| 49 | - ERROR |
| 50 | - WARNING |
| 51 | - INFO |
| 52 | - DEBUG (lowest) |
| 53 | - None turns all logging off. |
| 54 | |
| 55 | === Console === |
| 56 | |
| 57 | {{{#!python |
| 58 | settings.log.console = True |
| 59 | }}} |
| 60 | enables logging to the system error console (sys.stderr). |
| 61 | False disables console logging. |
| 62 | |
| 63 | === Log File === |
| 64 | |
| 65 | {{{#!python |
| 66 | settings.log.logfile = "/var/log/eden.log" |
| 67 | }}} |
| 68 | 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 |
| 69 | None disables logging to file. |
| 70 | |
| 71 | === Caller Info === |
| 72 | |
| 73 | 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): |
| 74 | {{{ |
| 75 | 2014-02-16 11:58:23 (applications/eden/modules/s3/s3rest.py 477 __init__) ERROR: Something went wrong: Example |
| 76 | }}} |