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):

  • EMERG
  • ALERT
  • CRIT
  • ERR
  • WARNING
  • NOTICE
  • INFO
  • DEBUG

Flag constants:

  • FLAG_LF - append '\n'
  • FLAG_FILE - filename:line
  • FLAG_PATH - full path:line

Notes about message arguments:

  • The logging functions accept varargs.
  • Only string, number, boolean and nil values 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 level are discarded.

Parameters:

  • level int One of the level constants (e.g. log.INFO, log.DEBUG).
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)
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.
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.
set_ident (ident)
Set syslog/file ident.

This also affects the prefix when logging to file/stdout.

Parameters:

  • ident string Identifier string.
generated by LDoc 1.5.0 Last updated 2026-04-09 14:48:22