hwylterm/logging
wrapper around std/logging to provide a fancy console logger
Types
HwylConsoleLogger = ref object of Logger useStderr*: bool ## If true, writes to stderr; otherwise, writes to stdout flushThreshold*: Level ## Only messages that are at or above this ## threshold will be flushed immediately
-
A logger that writes log messages to the console.
Create a new HwylConsoleLogger with the newHwylConsoleLogger proc.
Source Edit
Procs
proc addHandlers(handler: Logger) {....raises: [], tags: [], forbids: [].}
- Source Edit
proc newHwylConsoleLogger(levelThreshold = lvlAll; fmtPrefix = ""; fmtSep = "|"; fmtSuffix = "| "; useStderr = true; flushThreshold = defaultFlushThreshold; debugStyle = "faint"; infoStyle = "bold"; noticeStyle = "bold"; warnStyle = "bold yellow"; errorStyle = "bold red"; fatalStyle = "bold red"): HwylConsoleLogger {. ...raises: [], tags: [], forbids: [].}
- Creates a new HwylConsoleLogger. Source Edit
Methods
method log(logger: HwylConsoleLogger; level: Level; args: varargs[string, `$`]) {. ...gcsafe, raises: [], tags: [ReadIOEffect, TimeEffect, WriteIOEffect], forbids: [].}
-
Logs to the console with the given HwylConsoleLogger only.
This method ignores the list of registered handlers.
Whether the message is logged depends on both the ConsoleLogger's levelThreshold field and the global log filter set using the setLogFilter proc.
Note: Only error and fatal messages will cause the output buffer to be flushed immediately by default. Set flushThreshold when creating the logger to change this.
Source Edit