From a85dfde3d571ffc71868cd9aec54f2378a4440a4 Mon Sep 17 00:00:00 2001 From: Daylin Morgan Date: Mon, 30 Sep 2024 12:39:19 -0500 Subject: [PATCH] upgrade hwylterm --- pkgs/oizys-nim/default.nix | 2 +- pkgs/oizys-nim/nimble.lock | 10 +-- pkgs/oizys-nim/src/oizys.nim | 7 +- pkgs/oizys-nim/src/oizys/context.nim | 3 +- pkgs/oizys-nim/src/oizys/github.nim | 4 +- pkgs/oizys-nim/src/oizys/logging.nim | 117 --------------------------- pkgs/oizys-nim/src/oizys/nix.nim | 9 +-- 7 files changed, 14 insertions(+), 138 deletions(-) delete mode 100644 pkgs/oizys-nim/src/oizys/logging.nim diff --git a/pkgs/oizys-nim/default.nix b/pkgs/oizys-nim/default.nix index 38b4b56..4cc5117 100644 --- a/pkgs/oizys-nim/default.nix +++ b/pkgs/oizys-nim/default.nix @@ -8,5 +8,5 @@ buildNimblePackage { verions = "unstable"; src = lib.cleanSource ./.; nativeBuildInputs = [ openssl ]; - nimbleDepsHash = "sha256-A2sQy4x+QyqltV7B1rRh7uRPvv7pDtVNOXZZl5LrHCY="; + nimbleDepsHash = "sha256-3p+PdGkQmKwz5tzJwX0aun3kSOLw/lwzqRkR9+6ECQE="; } diff --git a/pkgs/oizys-nim/nimble.lock b/pkgs/oizys-nim/nimble.lock index 3ce63f1..beeb899 100644 --- a/pkgs/oizys-nim/nimble.lock +++ b/pkgs/oizys-nim/nimble.lock @@ -2,23 +2,23 @@ "version": 2, "packages": { "cligen": { - "version": "1.7.0", - "vcsRevision": "4193f802796f15559c81c6dd56724d6f20345917", + "version": "1.7.6", + "vcsRevision": "54f1da5d63cf7e116625e2392e85ae54c2b70719", "url": "https://github.com/c-blake/cligen.git", "downloadMethod": "git", "dependencies": [], "checksums": { - "sha1": "300bd7fdb6e48d2d98e34ed0661206b50331e99c" + "sha1": "853785ddace4ee4f3c6c21bdf7f5e9ff0358eb3f" } }, "hwylterm": { "version": "0.1.0", - "vcsRevision": "c2bcfd1f73dda97bd3e209c89e2abfe588f0977c", + "vcsRevision": "d852761831bd748db24b42f15bc8e2d286232295", "url": "https://github.com/daylinmorgan/hwylterm", "downloadMethod": "git", "dependencies": [], "checksums": { - "sha1": "1932229840c893c39acca0b50def19913678f5f0" + "sha1": "7de2a93a03bd0659d8d70cc7c08315e0a7f15439" } }, "jsony": { diff --git a/pkgs/oizys-nim/src/oizys.nim b/pkgs/oizys-nim/src/oizys.nim index 2285399..8b151e0 100644 --- a/pkgs/oizys-nim/src/oizys.nim +++ b/pkgs/oizys-nim/src/oizys.nim @@ -1,12 +1,11 @@ ## nix begat oizys import std/[os, tables, sequtils, strformat, strutils] -import hwylterm, hwylterm/cli -import oizys/[context, github, nix, overlay, logging] +import hwylterm, hwylterm/[cligen, logging] +import oizys/[context, github, nix, overlay]# 3, logging addHandler( newFancyConsoleLogger( - levelThreshold=lvlAll, - useStderr = true, + levelThreshold = lvlAll, fmtPrefix = $bb"[b magenta]oizys" ) ) diff --git a/pkgs/oizys-nim/src/oizys/context.nim b/pkgs/oizys-nim/src/oizys/context.nim index 379fbce..1fb6d66 100644 --- a/pkgs/oizys-nim/src/oizys/context.nim +++ b/pkgs/oizys-nim/src/oizys/context.nim @@ -1,7 +1,6 @@ import std/[logging, os, strformat, strutils] from std/nativesockets import getHostname -import hwylterm -import ./logging +import hwylterm, hwylterm/logging type OizysContext* = object diff --git a/pkgs/oizys-nim/src/oizys/github.nim b/pkgs/oizys-nim/src/oizys/github.nim index f5b63d0..40651f8 100644 --- a/pkgs/oizys-nim/src/oizys/github.nim +++ b/pkgs/oizys-nim/src/oizys/github.nim @@ -1,6 +1,6 @@ import std/[httpclient,logging, os, strformat, strutils, json, tables, tempfiles] -import jsony, hwylterm, zippy/ziparchives -import ./[logging, exec, context] +import jsony, hwylterm, hwylterm/logging, zippy/ziparchives +import ./[exec, context] # localPassC is used by zippy but the additional # module mangling on nixos somehow breaks localPassC diff --git a/pkgs/oizys-nim/src/oizys/logging.nim b/pkgs/oizys-nim/src/oizys/logging.nim deleted file mode 100644 index 12b625c..0000000 --- a/pkgs/oizys-nim/src/oizys/logging.nim +++ /dev/null @@ -1,117 +0,0 @@ -import std/[logging,strutils] -export logging - -import hwylterm - -var - handlers {.threadvar.}: seq[Logger] - -#[ -Level* = enum ## \ - lvlAll, ## All levels active - lvlDebug, ## Debug level and above are active - lvlInfo, ## Info level and above are active - lvlNotice, ## Notice level and above are active - lvlWarn, ## Warn level and above are active - lvlError, ## Error level and above are active - lvlFatal, ## Fatal level and above are active - lvlNone ## No levels active; nothing is logged -]# - -type - FancyConsoleLogger* = ref object of Logger - ## A logger that writes log messages to the console. - ## - ## Create a new ``FancyConsoleLogger`` with the `newFancyConsoleLogger proc - ## <#newConsoleLogger>`_. - ## - 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 - fmtPrefix: string - fmtSep: string - fmtStrs: array[Level, string] - - -const defaultFlushThreshold = lvlAll - -proc genFmtStr( - fmtPrefix, fmtSep, fmtSuffix, levelBb: string, - level: Level -): string = - var parts: seq[string] - if fmtPrefix != "": parts.add fmtPrefix - parts.add $LevelNames[level].bb(levelBb) - return parts.join(fmtSep) & fmtSuffix - - -proc newFancyConsoleLogger*( - levelThreshold = lvlAll, - fmtPrefix= "", - fmtSep = "|", - fmtSuffix ="| ", - useStderr = false, - flushThreshold = defaultFlushThreshold, - debugBb: string = "faint", - infoBb: string = "bold", - noticeBb: string = "bold", - warnBb: string = "bold yellow", - errorBb: string = "bold red", - fatalBb: string = "bold red" -): FancyConsoleLogger = - ## Creates a new `FancyConsoleLogger<#ConsoleLogger>`_. - new result - let fmtStrs: array[Level, string] = [ - genFmtStr(fmtPrefix,fmtSep, fmtSuffix, "", lvlAll), - genFmtStr(fmtPrefix,fmtSep, fmtSuffix, debugBb, lvlDebug), - genFmtStr(fmtPrefix,fmtSep, fmtSuffix, infobb, lvlInfo), - genFmtStr(fmtPrefix,fmtSep, fmtSuffix, noticeBb, lvlNotice), - genFmtStr(fmtPrefix,fmtSep, fmtSuffix, warnBb, lvlWarn), - genFmtStr(fmtPrefix,fmtSep, fmtSuffix, errorBb, lvlError), - genFmtStr(fmtPrefix,fmtSep, fmtSuffix, fatalBb, lvlFatal), - genFmtStr(fmtPrefix, fmtSep, fmtSuffix, "", lvlNone) - ] - result.fmtPrefix = fmtPrefix - result.fmtSep = fmtSep - result.levelThreshold = levelThreshold - result.flushThreshold = flushThreshold - result.useStderr = useStderr - result.fmtStrs = fmtStrs - - -method log*(logger: FancyConsoleLogger, level: Level, args: varargs[string, `$`]) {.gcsafe.} = - ## Logs to the console with the given `FancyConsoleLogger<#ConsoleLogger>`_ 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<#setLogFilter,Level>`_. - ## - ## **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. - - if level >= logger.levelThreshold: - let ln = substituteLog(logger.fmtStrs[level], level, args) - when defined(js): {.fatal: "handler does not support JS".} - try: - let handle = - if logger.useStderr: stderr - else: stdout - writeLine(handle, ln) - if level >= logger.flushThreshold: flushFile(handle) - except IOError: - discard - -proc addHandlers*(handler: Logger) = - handlers.add(handler) - -template errorQuit*(args: varargs[string, `$`]) = - error args - quit QuitFailure - -template fatalQuit*(args: varargs[string, `$`]) = - fatal args - quit QuitFailure - diff --git a/pkgs/oizys-nim/src/oizys/nix.nim b/pkgs/oizys-nim/src/oizys/nix.nim index 8c70007..8bb2b8c 100644 --- a/pkgs/oizys-nim/src/oizys/nix.nim +++ b/pkgs/oizys-nim/src/oizys/nix.nim @@ -3,9 +3,9 @@ import std/[ enumerate, os, sequtils, strformat, strutils, sugar, logging, tables ] -import hwylterm, jsony -import ./[context, exec, logging] +import hwylterm, hwylterm/logging, jsony +import ./[context, exec] proc nixCommand(cmd: string): string = result = "nix" @@ -257,8 +257,3 @@ proc nixBuildWithCache*(minimal: bool, name: string, rest:seq[string]) = let err = runCmd(cmd) quit err - - - - -