Skip to content

Commit f84ca05

Browse files
committed
Move documentation form new() to constructor method
1 parent 6e1f046 commit f84ca05

File tree

4 files changed

+24
-22
lines changed

4 files changed

+24
-22
lines changed

lua/structlog/logger.lua

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,11 @@
44
-- @type Logger
55
local Logger = {}
66

7+
--- Create a new logger
8+
-- @function Logger
9+
-- @param name The name of the logger
10+
-- @param level The logging level of the logger
11+
-- @param sinks The list of sinks to write the log entries in
712
setmetatable(Logger, {
813
__call = function(cls, ...)
914
return cls:new(...)
@@ -12,11 +17,6 @@ setmetatable(Logger, {
1217

1318
local Level = require("structlog.level")
1419

15-
--- Create a new logger
16-
-- @function new
17-
-- @param name The name of the logger
18-
-- @param level The logging level of the logger
19-
-- @param sinks The list of sinks to write the log entries in
2020
function Logger:new(name, level, sinks)
2121
local logger = {}
2222

lua/structlog/sinks/console.lua

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,18 +5,18 @@
55
local Console = {}
66
local KeyValue = require("structlog.formatters.key_value")
77

8+
--- Create a new console writer
9+
-- @function Console
10+
-- @param opts Optional parameters
11+
-- @param opts.async Make the logger async, default: True
12+
-- @param opts.processors The list of processors to chain the log entries in
13+
-- @param opts.formatter The formatter to format the log entries
814
setmetatable(Console, {
915
__call = function(cls, ...)
1016
return cls:new(...)
1117
end,
1218
})
1319

14-
--- Create a new console writer
15-
-- @function new
16-
-- @param opts Optional parameters
17-
-- @param opts.async Make the logger async, default: True
18-
-- @param opts.processors The list of processors to chain the log entries in
19-
-- @param opts.formatter The formatter to format the log entries
2020
function Console:new(opts)
2121
opts = opts or {}
2222

lua/structlog/sinks/file.lua

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,17 +5,18 @@
55
local File = {}
66
local KeyValue = require("structlog.formatters.key_value")
77

8+
--- Create a new file writer.
9+
-- @function File
10+
-- @param path The path to the logging file
11+
-- @param opts Optional parameters
12+
-- @param opts.processors The list of processors to chain the log entries in
13+
-- @param opts.formatter The formatter to format the log entries
814
setmetatable(File, {
915
__call = function(cls, ...)
1016
return cls:new(...)
1117
end,
1218
})
1319

14-
--- Create a new file writer.
15-
-- @param path The path to the logging file
16-
-- @param opts Optional parameters
17-
-- @param opts.processors The list of processors to chain the log entries in
18-
-- @param opts.formatter The formatter to format the log entries
1920
function File:new(path, opts)
2021
opts = opts or {}
2122

lua/structlog/sinks/rotating_file.lua

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,20 +5,21 @@
55
local RotatingFile = {}
66
local File = require("structlog.sinks.file")
77

8-
setmetatable(RotatingFile, {
9-
__call = function(cls, ...)
10-
return cls:new(...)
11-
end,
12-
})
13-
148
--- Create a new rotating file writer.
9+
-- @function RotatingFile
1510
-- @param path The path to the logging file
1611
-- @param opts Optional parameters
1712
-- @param opts.processors The list of processors to chain the log entries in
1813
-- @param opts.formatter The formatter to format the log entries
1914
-- @param opts.max_size Maximum size of the file in bytes
2015
-- @param opts.max_age Maximum age of the file is seconds
2116
-- @param opts.time_format The time format used for renaming the log, default: "%F-%H:%M:%S"
17+
setmetatable(RotatingFile, {
18+
__call = function(cls, ...)
19+
return cls:new(...)
20+
end,
21+
})
22+
2223
function RotatingFile:new(path, opts)
2324
opts = opts or {}
2425

0 commit comments

Comments
 (0)