feat(conf): ability to set log level in config

This commit is contained in:
2025-11-18 22:14:52 -03:00
parent ce1139e335
commit a7e8f3add0
4 changed files with 14 additions and 4 deletions

View File

@@ -24,6 +24,7 @@ hmacKey = "secretkey" # random key for cryptographic signing of video urls
base64Media = false # use base64 encoding for proxied media urls
enableRSS = true # set this to false to disable RSS feeds
enableDebug = false # enable request logs and debug endpoints (/.sessions)
logLevel = "info" # log level (debug, info, warn, error, fatal)
proxy = "" # http/https url, SOCKS proxies are not supported
proxyAuth = ""

View File

@@ -39,6 +39,7 @@ proc getConfig*(path: string): (Config, parseCfg.Config) =
minTokens: cfg.get("Config", "tokenCount", 10),
enableRss: cfg.get("Config", "enableRSS", true),
enableDebug: cfg.get("Config", "enableDebug", false),
logLevel: cfg.get("Config", "logLevel", ""),
proxy: cfg.get("Config", "proxy", ""),
proxyAuth: cfg.get("Config", "proxyAuth", "")
)

View File

@@ -52,10 +52,17 @@ initSessionPool(cfg, sessionsPath)
addHandler(new(ColoredLogger))
if cfg.enableDebug:
setLogFilter(lvlDebug)
else:
setLogFilter(lvlInfo)
let level = case cfg.logLevel.toLowerAscii
of "debug": lvlDebug
of "info": lvlInfo
of "warn": lvlWarn
of "error": lvlError
of "fatal": lvlFatal
of "none": lvlNone
else:
if cfg.enableDebug: lvlDebug else: lvlInfo
setLogFilter(level)
info &"Starting Nitter at {getUrlPrefix(cfg)}"

View File

@@ -285,6 +285,7 @@ type
minTokens*: int
enableRss*: bool
enableDebug*: bool
logLevel*: string
proxy*: string
proxyAuth*: string