Software /
code /
prosody
Diff
core/configmanager.lua @ 13745:994ea8d54b72 13.0
core.configmanager: Pass name and line number in context
Delays the string interpolation until the warning is logged, which may
slightly lower memory usage.
Allows retrieving the filename and line number easily.
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Sat, 22 Feb 2025 00:04:51 +0100 |
parent | 13744:34ac05f6bd10 |
line wrap: on
line diff
--- a/core/configmanager.lua Sat Feb 22 00:08:18 2025 +0100 +++ b/core/configmanager.lua Sat Feb 22 00:04:51 2025 +0100 @@ -48,7 +48,7 @@ function _M.get(host, key) local v = config[host][key]; if v and errors.is_error(v) then - log("warn", "%s", v.text); + log("warn", "%s:%d: %s", v.context.filename, v.context.fileline, v.text); return nil; end return v; @@ -376,10 +376,9 @@ else env.Credential = function() return errors.new({ - type = "continue", - text = ("%s:%d: Credential() requires the $CREDENTIALS_DIRECTORY environment variable to be set") - :format(config_file, get_line_number(config_file)); - }); + type = "continue"; + text = "Credential() requires the $CREDENTIALS_DIRECTORY environment variable to be set"; + }, { filename = config_file; fileline = get_line_number(config_file) }); end end