Log Module
#log.getFilename
string log.getFilename()
Returns the filename (including full path) of the file we are logging to.
#log.add
log.add(string msg)
Adds 'msg' into our log file. This includes timestamp prefix, and a trailing newline (\n).
Example:
log.add("Testing");-- Adds the following (with correct date-time) to your log file: 2018-09-17 18:01:55 : Testing
#log.addRaw
log.addRaw(string msg)
Adds 'msg' into our log file. This differs from log.add() as it does not include the timestamp.
#log.isOpen
boolean log.isOpen()
If a log was successfully opened for writing, returns true.
If some error prevented the log from being opened, returns false.
#log.setLevel
log.setLevel(number level)
Sets the minimum "level" that a message must be in order to be logged by the system.
Log levels follow RFC-5425.
Example:
log.setLevel(log.level.notice);
log.warning("This is a warning! It will be logged.");
log.notice("This is a boring notice. It will also be logged.");
log.notice("This is a debug message. It will be ignored, because it does not reach the set log level.");
Log level | Int value |
log.level.emergency | 0 |
log.level.alert | 1 |
log.level.critical | 2 |
log.level.error | 3 |
log.level.warning | 4 |
log.level.notice | 5 |
log.level.info | 6 |
log.level.debug | 7 |
Any message at or below your log level will be logged. For example, if your log level is log.level.error (5), then
only emergency, alert, critical, and error messages will be logged while warning, notice, info, and debug messages will be ignored.
Emergency messages will always be logged and cannot be ignored. By default, the log level is typically be log.level.info (6)
#log.emergency
log.emergency(string msg)
Log an emergency-level message.
Example:
log.emergency("Emergency message goes here");
#log.alert
log.alert(string msg)
Log an alert-level message.
Example:
log.alert("Alert message goes here");
#log.critical
log.critical(string msg)
Log an critical-level message.
Example:
log.critical("Critical message goes here");
#log.error
log.error(string msg)
Log an error-level message.
Example:
log.error("Error message goes here");
#log.warning
log.warning(string msg)
Log an warning-level message.
Example:
log.warning("Warning message goes here");
#log.notice
log.notice(string msg)
Log an notice-level message.
Example:
log.notice("Notice message goes here");
#log.info
log.info(string msg)
Log an info-level message.
Example:
log.info("Info message goes here");
#log.debug
log.debug(string msg)
Log an debug-level message.
Example:
log.debug("Debug message goes here");
Page last updated at 2024-03-27 00:14:11