build(types): lualugging
ci/woodpecker/push/lint Pipeline failed Details
ci/woodpecker/pr/lint Pipeline failed Details
ci/woodpecker/push/build unknown status Details
ci/woodpecker/pr/build unknown status Details

This commit is contained in:
Aire-One 2022-09-03 19:22:48 +02:00
parent 20752fbc41
commit 04e84d09ae
4 changed files with 113 additions and 0 deletions

110
types/logging.d.tl Normal file
View File

@ -0,0 +1,110 @@
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)
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)
DEBUG: Level
INFO: Level
WARN: Level
ERROR: Level
FATAL: Level
OFF: Level
end
local enum ConsoleDestination
"stdout"
"stderr"
end
local record ConsoleParameters
destination: ConsoleDestination
logPattern: string
logPatterns: { Level: string }
timestampPattern: string
logLevel: Level
end
local record FileParameters
filename: string
datePattern: string
logPattern: string
logPatterns: { Level: string }
timestampPattern: string
logLevel: Level
end
local record RollingFileParameters
filename: string
maxFileSize: number
maxBackupIndex: number
logPattern: string
logPatterns: { Level: string }
timestampPattern: string
logLevel: Level
end
local record Types
Level: Level
Append: Append
Log: Log
ConsoleDestination: ConsoleDestination
ConsoleParameters: ConsoleParameters
FileParameters: FileParameters
RollingFileParameters: RollingFileParameters
end
local record logging
_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
-- undocumented/private APIs
compilePattern: function(pattern: any): function(): string
prepareLogMsg: function(lpattern: string, dpattern: string, level: Level, message: string): string
tostring: function(value: any): string
-- 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
__types: Types
end
return logging

View File

@ -0,0 +1 @@
return require "logging".console

1
types/logging/file.d.tl Normal file
View File

@ -0,0 +1 @@
return require "logging".file

View File

@ -0,0 +1 @@
return require("logging").rolling_file