logger

Logger provides some rudimentary logging capabilities.

The Logger is used to output messages to STDERR or a named file. Each message is assigned a level, and only messages above or equal to a set level will be output. This allows the developer to control the level of detail output by the program. This implementation uses the same levels as Ruby's Logger class:

  1. unknown: An unknown message that should always be logged.
  2. fatal: An unhandleable error that results in a program crash.
  3. error: A handleable error condition.
  4. warn: A warning.
  5. info: Generic (useful) information about system operation.
  6. debug: Low-level information for developers.

Procedures

log_debug (l, message)

Log a message, at level "debug"


log_error (l, message)

Log a message, at level "error"


log_fatal (l, message)

Log a message, at level "fatal"


log_info (l, message)

Log a message, at level "info"


log_level (l, new_level)

Sets a new log level. The new level should be the string name of one of the log levels, as given above.


log_unknown (l, message)

Log a message, at level "unknown"


log_warn (l, message)

Log a message, at level "warn"


logger_close (l)

Closes the logger. It is important to call this if the logger is using a file output, as then the file will be closed.


logger_new (filename)

Creates a new logger object. It accepts one optional argument, which is the name of a file to save the log to. If no filename is provided, the logger will output to STDERR.


Home