feat(conf): ability to set log level in config
This commit is contained in:
@@ -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 = ""
|
||||
|
||||
|
||||
@@ -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", "")
|
||||
)
|
||||
|
||||
@@ -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)}"
|
||||
|
||||
|
||||
@@ -285,6 +285,7 @@ type
|
||||
minTokens*: int
|
||||
enableRss*: bool
|
||||
enableDebug*: bool
|
||||
logLevel*: string
|
||||
proxy*: string
|
||||
proxyAuth*: string
|
||||
|
||||
|
||||
Reference in New Issue
Block a user