Module eco.log
Logging utilities.
This module provides simple logging helpers backed by syslog/stdout/file.
- Default level:
INFO - Default flags:
FLAG_LF
Output backend selection:
- If stdout is a TTY, logs go to stdout.
- Otherwise logs go to syslog.
- If log.set_path is called with a non-empty path, logs are appended to that file.
Log level constants (syslog priorities):
EMERGALERTCRITERRWARNINGNOTICEINFODEBUG
Flag constants:
FLAG_LF- append '\n'FLAG_FILE- filename:lineFLAG_PATH- full path:line
Notes about message arguments:
- The logging functions accept varargs.
- Only string,
number,booleanandnilvalues are rendered; other types are ignored.
Functions
| set_level (level) | Set current log level. |
| debug ([...]) | Log a DEBUG message. |
| info ([...]) | Log an INFO message. |
| err ([...]) | Log an ERR message. |
| log (priority[, ...]) | Log a message at a specific priority. |
| set_path (path) | Set log output file path. |
| set_flags (flags) | Set log flags. |
| set_ident (ident) | Set syslog/file ident. |
Functions
- set_level (level)
-
Set current log level.
Messages with priority greater than
levelare discarded.Parameters:
- level
int
One of the level constants (e.g.
log.INFO,log.DEBUG).
- level
int
One of the level constants (e.g.
- debug ([...])
-
Log a DEBUG message.
Parameters:
- ... any Values to log. (optional)
- info ([...])
-
Log an INFO message.
Parameters:
- ... any Values to log. (optional)
- err ([...])
-
Log an ERR message.
Parameters:
- ... any Values to log. (optional)
- log (priority[, ...])
-
Log a message at a specific priority.
Parameters:
- priority
int
One of the level constants (e.g.
log.WARNING). - ... any Values to log. (optional)
- priority
int
One of the level constants (e.g.
- set_path (path)
-
Set log output file path.
When set to a non-empty path, logs are appended to that file. Passing an empty string resets output back to stdout/syslog.
Parameters:
- path
string
Output file path, or
''to reset.
- path
string
Output file path, or
- set_flags (flags)
-
Set log flags.
Combine flags using bitwise OR, e.g.
log.FLAG_LF | log.FLAG_FILE.Parameters:
- flags
int
Bitmask of
FLAG_*constants.
- flags
int
Bitmask of
- set_ident (ident)
-
Set syslog/file ident.
This also affects the prefix when logging to file/stdout.
Parameters:
- ident string Identifier string.