Merge pull request #229 from YunoHost/add-the-possibility-to-change-the-logging-level

add the possibility to change the logging level
This commit is contained in:
Alexandre Aubin 2024-03-29 18:49:13 +01:00 committed by GitHub
commit 7a4d99b077
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -46,8 +46,29 @@ end
logger = Logging.new(appender)
logger:setLevel(Logging.DEBUG)
function isValidLoggingLevel(level)
local validLoggingLevel = {
Logging.DEBUG, -- DEBUG
Logging.INFO, -- INFO
Logging.WARN, -- WARN
Logging.ERROR, -- ERROR
Logging.FATAL -- FATAL
}
for i, l in ipairs(validLoggingLevel)
do
if l == level then
return true
end
end
return false
end
conf = config.get_config()
if conf["logging"] and isValidLoggingLevel(conf["logging"]) then
logger:setLevel(conf["logging"])
else
logger:setLevel(Logging.INFO) -- INFO by default
end
-- You should see that in your Nginx error logs by default
ngx.log(ngx.INFO, "SSOwat ready")