aboutsummaryrefslogtreecommitdiffstats
path: root/core
diff options
context:
space:
mode:
authorKim Alvefur <zash@zash.se>2025-02-22 00:04:51 +0100
committerKim Alvefur <zash@zash.se>2025-02-22 00:04:51 +0100
commit6b1e05614238b1ceb0fb640ee4241697e10db638 (patch)
tree77d4c4f0717e7e4cfd3b377234135ab4598c6984 /core
parent5e41daac799c7195fd5885da254cbba13025cca6 (diff)
downloadprosody-6b1e05614238b1ceb0fb640ee4241697e10db638.tar.gz
prosody-6b1e05614238b1ceb0fb640ee4241697e10db638.zip
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.
Diffstat (limited to 'core')
-rw-r--r--core/configmanager.lua9
1 files changed, 4 insertions, 5 deletions
diff --git a/core/configmanager.lua b/core/configmanager.lua
index 526409e8..6c6b670b 100644
--- a/core/configmanager.lua
+++ b/core/configmanager.lua
@@ -48,7 +48,7 @@ end
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 @@ do
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