Removed nifty; compiling with --mm:refc
h3rald h3rald@h3rald.com
Tue, 15 Aug 2023 10:36:41 +0000
8 files changed,
79 insertions(+),
67 deletions(-)
M
min.nimble
→
min.nimble
@@ -18,8 +18,3 @@ requires "nim >= 1.6.12"
requires "zippy >= 0.5.6 & < 0.6.0" requires "nimquery >= 2.0.1 & < 3.0.0" requires "minline >= 0.1.1 & < 0.2.0" - -before install: - exec "nimble install -y nifty" - exec "nifty remove -f" - exec "nifty install"
A
minpkg/niftylogger.nim
@@ -0,0 +1,73 @@
+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
M
next-release.md
→
next-release.md
@@ -1,4 +1,4 @@
### Fixes and Improvements -* Fixed compilation errors with Nim 2.0. - +* Removed depentency unnecessary dependency on nifty. +* Now compiling using `--mm:refc` to decrease memory usage.
D
nifty.json
@@ -1,56 +0,0 @@
-{ - "storage": "minpkg/packages", - "commands": { - "install": { - "git+src": { - "cmd": "git clone {{src}} --depth 1" - }, - "nimble+name": { - "cmd": "nimble install {{name}}" - }, - "git+src+tag": { - "cmd": "git clone --branch {{tag}} {{src}} --depth 1" - }, - "curl+src+name": { - "cmd": "curl {{src}} -o {{name}}" - }, - "_syntax": "install [<package>]", - "_description": "Installs the specified package (or all mapped packages) to the storage directory." - }, - "update": { - "git+name": { - "cmd": "git pull", - "pwd": "{{name}}" - }, - "nimble+name": { - "cmd": "nimble upgrade {{name}}" - }, - "curl+src+name": { - "cmd": "curl {{src}} -o {{name}}" - }, - "_syntax": "update [<package>]", - "_description": "Updates the specified previously-installed package (or all packages)." - }, - "upgrade": { - "_syntax": "upgrade [<package>]", - "_description": "Upgrades the specified previously-installed package (or all packages).", - "git+name": { - "cmd": "git pull", - "pwd": "{{name}}" - }, - "nimble+name": { - "cmd": "nimble upgrade {{name}}" - }, - "curl+src+name": { - "cmd": "curl {{src}} -o {{name}}" - } - } - }, - "packages": { - "niftylogger.nim": { - "name": "niftylogger.nim", - "src": "https://raw.githubusercontent.com/h3rald/nifty/master/src/niftypkg/niftylogger.nim", - "curl": true - } - } -}
M
site/settings.json
→
site/settings.json
@@ -6,5 +6,5 @@ "rules": "rules.min",
"temp": "temp", "templates": "templates", "title": "min language", - "version": "0.39.1" + "version": "0.39.2" }