From 7267c3b112e0838a29004c869f600d5be4f30dbe Mon Sep 17 00:00:00 2001 From: Aire-One Date: Sat, 10 Sep 2022 05:54:57 +0200 Subject: [PATCH] Add lualogging (#38) * add lualogging initial support --- types/lualogging/logging.d.tl | 97 ++++++++++++++++++++++ types/lualogging/logging/console.d.tl | 1 + types/lualogging/logging/file.d.tl | 1 + types/lualogging/logging/rolling_file.d.tl | 1 + 4 files changed, 100 insertions(+) create mode 100644 types/lualogging/logging.d.tl create mode 100644 types/lualogging/logging/console.d.tl create mode 100644 types/lualogging/logging/file.d.tl create mode 100644 types/lualogging/logging/rolling_file.d.tl diff --git a/types/lualogging/logging.d.tl b/types/lualogging/logging.d.tl new file mode 100644 index 0000000..57b9927 --- /dev/null +++ b/types/lualogging/logging.d.tl @@ -0,0 +1,97 @@ +local enum Level + "DEBUG" + "INFO" + "WARN" + "ERROR" + "FATAL" + "OFF" +end + +local type Append = function(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 record logging + Level: Level + Append: Append + Log: Log + + _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) + record ConsoleParameters + enum ConsoleDestination + "stdout" + "stderr" + end + + destination: ConsoleDestination + logPattern: string + logPatterns: { Level : string } + timestampPattern: string + logLevel: Level + end + console: Append + + record FileParameters + filename: string + datePattern: string + logPattern: string + logPatterns: { Level : string } + timestampPattern: string + logLevel: Level + end + file: Append + + record RollingFileParameters + filename: string + maxFileSize: number + maxBackupIndex: number + logPattern: string + logPatterns: { Level : string } + timestampPattern: string + logLevel: Level + end + rolling_file: Append + + -- TODO : add more appenders +end + +return logging diff --git a/types/lualogging/logging/console.d.tl b/types/lualogging/logging/console.d.tl new file mode 100644 index 0000000..a2d72d1 --- /dev/null +++ b/types/lualogging/logging/console.d.tl @@ -0,0 +1 @@ +return require "logging".console diff --git a/types/lualogging/logging/file.d.tl b/types/lualogging/logging/file.d.tl new file mode 100644 index 0000000..6b6167e --- /dev/null +++ b/types/lualogging/logging/file.d.tl @@ -0,0 +1 @@ +return require "logging".file diff --git a/types/lualogging/logging/rolling_file.d.tl b/types/lualogging/logging/rolling_file.d.tl new file mode 100644 index 0000000..4b943da --- /dev/null +++ b/types/lualogging/logging/rolling_file.d.tl @@ -0,0 +1 @@ +return require("logging").rolling_file