mirror of
https://github.com/daylinmorgan/hwylterm.git
synced 2024-11-16 14:30:44 -06:00
update logger name
This commit is contained in:
parent
9462d99d95
commit
c8c66648cc
1 changed files with 12 additions and 9 deletions
|
@ -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.
|
||||||
##
|
##
|
||||||
|
|
Loading…
Reference in a new issue