all repos — min @ fa29a21dd2fddd4fd2ffd34012adc7aa5522a435

A small but practical concatenative programming language.

Fixes.
h3rald h3rald@h3rald.com
Tue, 15 Aug 2023 12:57:24 +0000
commit

fa29a21dd2fddd4fd2ffd34012adc7aa5522a435

parent

9c77b1e723357dab973f8dac48d5c46c2fa77cae

2 files changed, 1 insertions(+), 74 deletions(-)

jump to
M min.nimmin.nim

@@ -7,7 +7,7 @@ os,

algorithm, minline, logging, - minpkg/niftylogger, + minpkg/core/niftylogger, minpkg/core/baseutils, minpkg/core/env, minpkg/core/parser,
D minpkg/niftylogger.nim

@@ -1,73 +0,0 @@

-import - logging, - strutils, - terminal, - std/exitprocs - -if isatty(stdin): - addExitProc(resetAttributes) - -type - NiftyLogger* = ref object of Logger - -proc logPrefix*(level: Level): tuple[msg: string, color: ForegroundColor] = - case level: - of lvlDebug: - return ("---", fgMagenta) - of lvlInfo: - return ("(i)", fgCyan) - of lvlNotice: - return (" ", fgWhite) - of lvlWarn: - return ("(!)", fgYellow) - of lvlError: - return ("(!)", fgRed) - of lvlFatal: - return ("(x)", fgRed) - else: - return (" ", fgWhite) - -method log*(logger: NiftyLogger; level: Level; args: varargs[string, `$`]) = - var f = stdout - if level >= getLogFilter() and level >= logger.levelThreshold: - if level >= lvlWarn: - f = stderr - let ln = substituteLog(logger.fmtStr, level, args) - let prefix = level.logPrefix() - f.setForegroundColor(prefix.color) - f.write(prefix.msg) - f.write(ln) - resetAttributes() - f.write("\n") - if level in {lvlError, lvlFatal}: flushFile(f) - -proc newNiftyLogger*(levelThreshold = lvlAll; fmtStr = " "): NiftyLogger = - new result - result.fmtStr = fmtStr - result.levelThreshold = levelThreshold - -proc getLogLevel*(): string = - return LevelNames[getLogFilter()].toLowerAscii - -proc setLogLevel*(val: var string): string {.discardable.} = - var lvl: Level - case val: - of "debug": - lvl = lvlDebug - of "info": - lvl = lvlInfo - of "notice": - lvl = lvlNotice - of "warn": - lvl = lvlWarn - of "error": - lvl = lvlError - of "fatal": - lvl = lvlFatal - of "none": - lvl = lvlNone - else: - val = "warn" - lvl = lvlWarn - setLogFilter(lvl) - return val