Skip to content

Commit 147ee4a

Browse files
committed
simplify log opts
1 parent 41cf92a commit 147ee4a

File tree

5 files changed

+45
-90
lines changed

5 files changed

+45
-90
lines changed

lua/eca/commands.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,7 @@ function M.setup()
194194
elseif subcommand == "log_path" then
195195
local log_path = Logger.get_log_path()
196196
if log_path then
197-
Utils.info("ECA log file: " .. log_path, { nofity_only = true })
197+
Utils.info("ECA log file: " .. log_path, { notify = true })
198198
else
199199
Utils.info("File logging is disabled")
200200
end

lua/eca/logger.lua

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ end
112112
--- Main logging function
113113
---@param message string
114114
---@param level integer
115-
---@param opts? {title?: string, once?: boolean, file_only?: boolean, notify_only?: boolean}
115+
---@param opts? {title?: string, once?: boolean, file?: boolean, notify?: boolean}
116116
function M.log(message, level, opts)
117117
opts = opts or {}
118118

@@ -126,16 +126,14 @@ function M.log(message, level, opts)
126126
return
127127
end
128128

129-
-- Console notification
130-
if config.log.notify and not opts.file_only then
129+
if opts.notify then
131130
vim.notify(message, level, {
132131
title = opts.title or "ECA",
133132
once = opts.once,
134133
})
135134
end
136135

137-
-- File logging
138-
if config.log.file and not opts.notify_only then
136+
if opts.file then
139137
local log_path = resolve_log_path(config.log.file)
140138
if log_path then
141139
-- Ensure parent directory exists
@@ -161,28 +159,28 @@ end
161159

162160
--- Log debug message
163161
---@param message string
164-
---@param opts? {title?: string, once?: boolean, file_only?: boolean, notify_only?: boolean}
162+
---@param opts? {title?: string, once?: boolean, file?: boolean, notify?: boolean}
165163
function M.debug(message, opts)
166164
M.log(message, vim.log.levels.DEBUG, opts)
167165
end
168166

169167
--- Log info message
170168
---@param message string
171-
---@param opts? {title?: string, once?: boolean, file_only?: boolean, notify_only?: boolean}
169+
---@param opts? {title?: string, once?: boolean, file?: boolean, notify?: boolean}
172170
function M.info(message, opts)
173171
M.log(message, vim.log.levels.INFO, opts)
174172
end
175173

176174
--- Log warn message
177175
---@param message string
178-
---@param opts? {title?: string, once?: boolean, file_only?: boolean, notify_only?: boolean}
176+
---@param opts? {title?: string, once?: boolean, file?: boolean, notify?: boolean}
179177
function M.warn(message, opts)
180178
M.log(message, vim.log.levels.WARN, opts)
181179
end
182180

183181
--- Log error message
184182
---@param message string
185-
---@param opts? {title?: string, once?: boolean, file_only?: boolean, notify_only?: boolean}
183+
---@param opts? {title?: string, once?: boolean, file?: boolean, notify?: boolean}
186184
function M.error(message, opts)
187185
M.log(message, vim.log.levels.ERROR, opts)
188186
end

lua/eca/server.lua

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -90,9 +90,10 @@ function M:_log_to_file(level, message)
9090
vim_level = vim.log.levels.ERROR
9191
end
9292

93-
-- Log with file_only to avoid duplicate notifications
93+
-- Log to file only to avoid duplicate notifications
9494
Logger.log(message, vim_level, {
95-
file_only = true,
95+
file = true,
96+
notify = false,
9697
title = "SERVER"
9798
})
9899
end

lua/eca/utils.lua

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ local CONSTANTS = {
88
}
99

1010
---@param msg string
11-
---@param opts? {title?: string, once?: boolean, file_only?: boolean, notify_only?: boolean}
11+
---@param opts? {title?: string, once?: boolean, file?: boolean, notify?: boolean}
1212
function M.debug(msg, opts)
1313
opts = opts or {}
1414
local Config = require("eca.config")
@@ -19,23 +19,23 @@ function M.debug(msg, opts)
1919
end
2020

2121
---@param msg string
22-
---@param opts? {title?: string, once?: boolean, file_only?: boolean, notify_only?: boolean}
22+
---@param opts? {title?: string, once?: boolean, file?: boolean, notify?: boolean}
2323
function M.info(msg, opts)
2424
opts = opts or {}
2525
local Logger = require("eca.logger")
2626
Logger.info(msg, opts)
2727
end
2828

2929
---@param msg string
30-
---@param opts? {title?: string, once?: boolean, file_only?: boolean, notify_only?: boolean}
30+
---@param opts? {title?: string, once?: boolean, file?: boolean, notify?: boolean}
3131
function M.warn(msg, opts)
3232
opts = opts or {}
3333
local Logger = require("eca.logger")
3434
Logger.warn(msg, opts)
3535
end
3636

3737
---@param msg string
38-
---@param opts? {title?: string, once?: boolean, file_only?: boolean, notify_only?: boolean}
38+
---@param opts? {title?: string, once?: boolean, file?: boolean, notify?: boolean}
3939
function M.error(msg, opts)
4040
opts = opts or {}
4141
local Logger = require("eca.logger")

0 commit comments

Comments
 (0)