Logger
Logger is a general purpose to file logger.
It can be gotten with: Logger = pos.require('logger')
Logger(path: string, printToConsole: boolean|nil)
Creates a new logger at path
.
If printToConsole
logged messages will be printed to the shell
Type | Name | Description |
---|---|---|
string |
path |
Path to log file (Read only) |
integer |
level |
Log level, defaults to 5 |
WriteHandle |
file |
File handle for log file |
boolean |
print |
If messages should also be printed to the shell |
Return | Name | Description |
---|---|---|
nil |
setLevel(level: integer) |
Sets the logging level |
nil |
flush() |
Flushes the log to file, saving the current log. Called after every write(str) |
nil |
write(str: string) |
Write a line to the log and flush. Prints to shell if print is true |
nil |
debug(message: string) |
Writes a DEBUG message to the log if level is 5 or higher |
nil |
info(message: string) |
Writes a INFO message to the log if level is 4 or higher |
nil |
warn(message: string) |
Writes a WARN message to the log if level is 3 or higher |
nil |
error(message: string) |
Writes a ERROR message to the log if level is 2 or higher |
nil |
fatal(message: string) |
Writes a FATAL message to the log if level is 1 or higher |