update logger name

This commit is contained in:
Daylin Morgan 2024-10-30 22:15:59 -05:00
parent 9462d99d95
commit c8c66648cc
Signed by: daylin
GPG key ID: 950D13E9719334AD

View file

@ -1,6 +1,9 @@
## hwylterm/logging
##
## wrapper around std/logging to provide a fancy console logger
import std/[logging, strutils] import std/[logging, strutils]
export logging export logging
import ./bbansi import ./bbansi
var var
@ -19,10 +22,10 @@ Level* = enum ## \
]# ]#
type type
FancyConsoleLogger* = ref object of Logger HwylConsoleLogger* = ref object of Logger
## A logger that writes log messages to the console. ## A logger that writes log messages to the console.
## ##
## Create a new ``FancyConsoleLogger`` with the `newFancyConsoleLogger proc ## Create a new ``HwylConsoleLogger`` with the `newHwylConsoleLogger proc
## <#newConsoleLogger>`_. ## <#newConsoleLogger>`_.
## ##
useStderr*: bool ## If true, writes to stderr; otherwise, writes to stdout useStderr*: bool ## If true, writes to stderr; otherwise, writes to stdout
@ -50,11 +53,11 @@ proc genFmtStr(
): string = ): string =
var parts: seq[string] var parts: seq[string]
if fmtPrefix != "": parts.add fmtPrefix if fmtPrefix != "": parts.add fmtPrefix
parts.add $LevelNames[level].bb(levelStyle) parts.add $LevelNames[level].alignLeft(6).bb(levelStyle)
return parts.join(fmtSep) & fmtSuffix return parts.join(fmtSep) & fmtSuffix
proc newFancyConsoleLogger*( proc newHwylConsoleLogger*(
levelThreshold = lvlAll, levelThreshold = lvlAll,
fmtPrefix = "", fmtPrefix = "",
fmtSep = "|", fmtSep = "|",
@ -67,8 +70,8 @@ proc newFancyConsoleLogger*(
warnStyle = "bold yellow", warnStyle = "bold yellow",
errorStyle = "bold red", errorStyle = "bold red",
fatalStyle = "bold red" fatalStyle = "bold red"
): FancyConsoleLogger = ): HwylConsoleLogger =
## Creates a new `FancyConsoleLogger<#ConsoleLogger>`_. ## Creates a new `HwylConsoleLogger<#HwylConsoleLogger>`_.
new result new result
## log needs to be gcsafe so we pregenerate the log formats when making the handler ## log needs to be gcsafe so we pregenerate the log formats when making the handler
let fmtStrs: array[Level, string] = [ let fmtStrs: array[Level, string] = [
@ -89,8 +92,8 @@ proc newFancyConsoleLogger*(
result.fmtStrs = fmtStrs result.fmtStrs = fmtStrs
method log*(logger: FancyConsoleLogger, level: Level, args: varargs[string, `$`]) {.gcsafe.} = method log*(logger: HwylConsoleLogger, level: Level, args: varargs[string, `$`]) {.gcsafe.} =
## Logs to the console with the given `FancyConsoleLogger<#ConsoleLogger>`_ only. ## Logs to the console with the given `HwylConsoleLogger<#HwylConsoleLogger>`_ only.
## ##
## This method ignores the list of registered handlers. ## This method ignores the list of registered handlers.
## ##