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

View file

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

View file

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

File diff suppressed because it is too large Load diff