2022-09-03 19:22:48 +02:00
|
|
|
local enum Level
|
|
|
|
"DEBUG"
|
|
|
|
"INFO"
|
|
|
|
"WARN"
|
|
|
|
"ERROR"
|
|
|
|
"FATAL"
|
|
|
|
"OFF"
|
|
|
|
end
|
|
|
|
|
|
|
|
local type Append = function<T>(params: T, ...: any): Log
|
|
|
|
|
|
|
|
local record Log
|
|
|
|
append: Append
|
|
|
|
setLevel: function (self: Log, level: Level)
|
|
|
|
log: function(self: Log, level: Level, ...: any)
|
|
|
|
getPrint: function(self: Log, level: Level): function(...: any)
|
|
|
|
|
2022-09-09 23:50:39 +02:00
|
|
|
debug: function(self: Log, ...: any)
|
|
|
|
info: function(self: Log, ...: any)
|
|
|
|
warn: function(self: Log, ...: any)
|
|
|
|
error: function(self: Log, ...: any)
|
|
|
|
fatal: function(self: Log, ...: any)
|
2022-09-03 19:22:48 +02:00
|
|
|
|
|
|
|
DEBUG: Level
|
|
|
|
INFO: Level
|
|
|
|
WARN: Level
|
|
|
|
ERROR: Level
|
|
|
|
FATAL: Level
|
|
|
|
OFF: Level
|
|
|
|
end
|
|
|
|
|
|
|
|
|
2022-09-09 23:50:39 +02:00
|
|
|
local record logging
|
2022-09-03 19:22:48 +02:00
|
|
|
Level: Level
|
|
|
|
Append: Append
|
|
|
|
Log: Log
|
|
|
|
|
2022-09-09 23:50:39 +02:00
|
|
|
enum ConsoleDestination
|
|
|
|
"stdout"
|
|
|
|
"stderr"
|
|
|
|
end
|
|
|
|
|
|
|
|
record ConsoleParameters
|
|
|
|
destination: ConsoleDestination
|
|
|
|
logPattern: string
|
|
|
|
logPatterns: { Level: string }
|
|
|
|
timestampPattern: string
|
|
|
|
logLevel: Level
|
|
|
|
end
|
|
|
|
|
|
|
|
record FileParameters
|
|
|
|
filename: string
|
|
|
|
datePattern: string
|
|
|
|
logPattern: string
|
|
|
|
logPatterns: { Level: string }
|
|
|
|
timestampPattern: string
|
|
|
|
logLevel: Level
|
|
|
|
end
|
|
|
|
|
|
|
|
record RollingFileParameters
|
|
|
|
filename: string
|
|
|
|
maxFileSize: number
|
|
|
|
maxBackupIndex: number
|
|
|
|
logPattern: string
|
|
|
|
logPatterns: { Level: string }
|
|
|
|
timestampPattern: string
|
|
|
|
logLevel: Level
|
|
|
|
end
|
|
|
|
|
2022-09-03 19:22:48 +02:00
|
|
|
_COPYRIGHT: string
|
|
|
|
_DESCRIPTION: string
|
|
|
|
_VERSION: string
|
|
|
|
|
|
|
|
DEBUG: Level
|
|
|
|
INFO: Level
|
|
|
|
WARN: Level
|
|
|
|
ERROR: Level
|
|
|
|
FATAL: Level
|
|
|
|
OFF: Level
|
|
|
|
|
|
|
|
new: function(append: function(self: Log, level: Level, msg: string | function), startLevel: Level): Log
|
|
|
|
buildLogPatterns: function(patterns: table, default: string): table
|
|
|
|
defaultLogPatterns: function(patt: string | table): table
|
|
|
|
defaultTimestampPattern: function(patt: string): string
|
|
|
|
defaultLevel: function(level: Level): Level
|
|
|
|
defaultLogger: function(logger: Log): Log
|
|
|
|
|
|
|
|
-- Deprecated
|
|
|
|
getDeprecatedParams: function(lst: table, ...: any)
|
|
|
|
|
|
|
|
-- Appenders (dynamically added to logging when required)
|
|
|
|
console: Append<ConsoleParameters>
|
|
|
|
file: Append<FileParameters>
|
|
|
|
rolling_file: Append<RollingFileParameters>
|
|
|
|
-- TODO : add more appenders
|
|
|
|
end
|
|
|
|
|
2022-09-09 23:50:39 +02:00
|
|
|
return logging
|