keep console logger handy to update

This commit is contained in:
Daylin Morgan 2024-11-19 13:41:25 -06:00
parent a8ce1b651e
commit 8114ac1b3b
Signed by: daylin
GPG key ID: 950D13E9719334AD
4 changed files with 12 additions and 1175 deletions

View file

@ -33,7 +33,7 @@ hwylCli:
? "set minimal" ? "set minimal"
- m - m
preSub: preSub:
setupLoggers(debug) setupLoggers()
updateContext(host, flake, debug, resetCache) updateContext(host, flake, debug, resetCache)
subcommands: subcommands:
@ -69,7 +69,6 @@ hwylCli:
# when really I want it to only happen in the lowest "subcommand" # when really I want it to only happen in the lowest "subcommand"
# needs to be fixed in hwylterm # needs to be fixed in hwylterm
preSub: preSub:
setupLoggers(debug)
updateContext(host, flake, debug, resetCache) updateContext(host, flake, debug, resetCache)
subcommands: subcommands:
[update] [update]

View file

@ -1,6 +1,7 @@
import std/[logging, os, strformat, strutils] import std/[logging, os, strformat, strutils]
from std/nativesockets import getHostname from std/nativesockets import getHostname
import hwylterm, hwylterm/logging import hwylterm, hwylterm/logging
import ./logging
type type
OizysContext* = object OizysContext* = object
@ -36,6 +37,8 @@ proc updateContext*(
) = ) =
if host.len > 0: oc.hosts = host if host.len > 0: oc.hosts = host
oc.debug = debug oc.debug = debug
if debug:
consoleLogger.levelThreshold = lvlAll
oc.resetCache = resetCache oc.resetCache = resetCache
if flake != "": if flake != "":
oc.flake = oc.flake =

View file

@ -25,16 +25,16 @@ proc getOizysLogPath(): string =
setLogFilter(lvlAll) setLogFilter(lvlAll)
proc setupLoggers*(debug: bool) = var consoleLogger* =
let logLevel =
if not debug: lvlInfo
else: lvlAll
addHandler(
newHwylConsoleLogger( newHwylConsoleLogger(
fmtPrefix = $bb"[b magenta]oizys", fmtPrefix = $bb"[b magenta]oizys",
fmtSuffix = " ", fmtSuffix = " ",
levelThreshold = logLevel levelThreshold = lvlInfo
) )
proc setupLoggers*() =
addHandler(
consoleLogger
) )
addHandler( addHandler(
newRollingFileLogger( newRollingFileLogger(

File diff suppressed because it is too large Load diff