mirror of
https://github.com/daylinmorgan/oizys.git
synced 2024-11-05 06:03:15 -06:00
upgrade hwylterm
This commit is contained in:
parent
b801e750dc
commit
a85dfde3d5
7 changed files with 14 additions and 138 deletions
|
@ -8,5 +8,5 @@ buildNimblePackage {
|
||||||
verions = "unstable";
|
verions = "unstable";
|
||||||
src = lib.cleanSource ./.;
|
src = lib.cleanSource ./.;
|
||||||
nativeBuildInputs = [ openssl ];
|
nativeBuildInputs = [ openssl ];
|
||||||
nimbleDepsHash = "sha256-A2sQy4x+QyqltV7B1rRh7uRPvv7pDtVNOXZZl5LrHCY=";
|
nimbleDepsHash = "sha256-3p+PdGkQmKwz5tzJwX0aun3kSOLw/lwzqRkR9+6ECQE=";
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,23 +2,23 @@
|
||||||
"version": 2,
|
"version": 2,
|
||||||
"packages": {
|
"packages": {
|
||||||
"cligen": {
|
"cligen": {
|
||||||
"version": "1.7.0",
|
"version": "1.7.6",
|
||||||
"vcsRevision": "4193f802796f15559c81c6dd56724d6f20345917",
|
"vcsRevision": "54f1da5d63cf7e116625e2392e85ae54c2b70719",
|
||||||
"url": "https://github.com/c-blake/cligen.git",
|
"url": "https://github.com/c-blake/cligen.git",
|
||||||
"downloadMethod": "git",
|
"downloadMethod": "git",
|
||||||
"dependencies": [],
|
"dependencies": [],
|
||||||
"checksums": {
|
"checksums": {
|
||||||
"sha1": "300bd7fdb6e48d2d98e34ed0661206b50331e99c"
|
"sha1": "853785ddace4ee4f3c6c21bdf7f5e9ff0358eb3f"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"hwylterm": {
|
"hwylterm": {
|
||||||
"version": "0.1.0",
|
"version": "0.1.0",
|
||||||
"vcsRevision": "c2bcfd1f73dda97bd3e209c89e2abfe588f0977c",
|
"vcsRevision": "d852761831bd748db24b42f15bc8e2d286232295",
|
||||||
"url": "https://github.com/daylinmorgan/hwylterm",
|
"url": "https://github.com/daylinmorgan/hwylterm",
|
||||||
"downloadMethod": "git",
|
"downloadMethod": "git",
|
||||||
"dependencies": [],
|
"dependencies": [],
|
||||||
"checksums": {
|
"checksums": {
|
||||||
"sha1": "1932229840c893c39acca0b50def19913678f5f0"
|
"sha1": "7de2a93a03bd0659d8d70cc7c08315e0a7f15439"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"jsony": {
|
"jsony": {
|
||||||
|
|
|
@ -1,12 +1,11 @@
|
||||||
## nix begat oizys
|
## nix begat oizys
|
||||||
import std/[os, tables, sequtils, strformat, strutils]
|
import std/[os, tables, sequtils, strformat, strutils]
|
||||||
import hwylterm, hwylterm/cli
|
import hwylterm, hwylterm/[cligen, logging]
|
||||||
import oizys/[context, github, nix, overlay, logging]
|
import oizys/[context, github, nix, overlay]# 3, logging
|
||||||
|
|
||||||
addHandler(
|
addHandler(
|
||||||
newFancyConsoleLogger(
|
newFancyConsoleLogger(
|
||||||
levelThreshold=lvlAll,
|
levelThreshold = lvlAll,
|
||||||
useStderr = true,
|
|
||||||
fmtPrefix = $bb"[b magenta]oizys"
|
fmtPrefix = $bb"[b magenta]oizys"
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
import std/[logging, os, strformat, strutils]
|
import std/[logging, os, strformat, strutils]
|
||||||
from std/nativesockets import getHostname
|
from std/nativesockets import getHostname
|
||||||
import hwylterm
|
import hwylterm, hwylterm/logging
|
||||||
import ./logging
|
|
||||||
|
|
||||||
type
|
type
|
||||||
OizysContext* = object
|
OizysContext* = object
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
import std/[httpclient,logging, os, strformat, strutils, json, tables, tempfiles]
|
import std/[httpclient,logging, os, strformat, strutils, json, tables, tempfiles]
|
||||||
import jsony, hwylterm, zippy/ziparchives
|
import jsony, hwylterm, hwylterm/logging, zippy/ziparchives
|
||||||
import ./[logging, exec, context]
|
import ./[exec, context]
|
||||||
|
|
||||||
# localPassC is used by zippy but the additional
|
# localPassC is used by zippy but the additional
|
||||||
# module mangling on nixos somehow breaks localPassC
|
# module mangling on nixos somehow breaks localPassC
|
||||||
|
|
|
@ -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
|
|
||||||
|
|
|
@ -3,9 +3,9 @@ import std/[
|
||||||
enumerate, os, sequtils, strformat,
|
enumerate, os, sequtils, strformat,
|
||||||
strutils, sugar, logging, tables
|
strutils, sugar, logging, tables
|
||||||
]
|
]
|
||||||
import hwylterm, jsony
|
import hwylterm, hwylterm/logging, jsony
|
||||||
import ./[context, exec, logging]
|
|
||||||
|
|
||||||
|
import ./[context, exec]
|
||||||
|
|
||||||
proc nixCommand(cmd: string): string =
|
proc nixCommand(cmd: string): string =
|
||||||
result = "nix"
|
result = "nix"
|
||||||
|
@ -257,8 +257,3 @@ proc nixBuildWithCache*(minimal: bool, name: string, rest:seq[string]) =
|
||||||
let err = runCmd(cmd)
|
let err = runCmd(cmd)
|
||||||
quit err
|
quit err
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue