mirror of
https://github.com/daylinmorgan/oizys.git
synced 2024-12-21 05:10:45 -06:00
Compare commits
3 commits
a287bee602
...
a459ea2ad1
Author | SHA1 | Date | |
---|---|---|---|
a459ea2ad1 | |||
a85dfde3d5 | |||
b801e750dc |
8 changed files with 42 additions and 168 deletions
54
flake.lock
54
flake.lock
|
@ -357,11 +357,11 @@
|
|||
"xdph": "xdph"
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1727679999,
|
||||
"narHash": "sha256-NWF3SKLMFjM0M93PDWM9+wKbc5XcnJEmojiZdNdPpUw=",
|
||||
"lastModified": 1727714556,
|
||||
"narHash": "sha256-l4cPDA3xGtGdQmdSCAO2VyWg9xwW6//KwDYefdWtovQ=",
|
||||
"ref": "refs/heads/main",
|
||||
"rev": "f6387536f62454f82039b42f641cd8c44153ad47",
|
||||
"revCount": 5281,
|
||||
"rev": "5c6c300abfea2539ffad9bcbf857325eec5ab765",
|
||||
"revCount": 5285,
|
||||
"submodules": true,
|
||||
"type": "git",
|
||||
"url": "https://github.com/hyprwm/Hyprland/"
|
||||
|
@ -547,11 +547,11 @@
|
|||
"nixpkgs-lib": "nixpkgs-lib_2"
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1727611937,
|
||||
"narHash": "sha256-VTtaGRJGFWQzQd7u7iHUJiUUyMbJ3Jcv/ZsXlBXw0Ok=",
|
||||
"lastModified": 1727710043,
|
||||
"narHash": "sha256-NpTnTg8oOVvntlTi/t8BUe5msrMmkiZFiOW22fc7B+g=",
|
||||
"owner": "nix-community",
|
||||
"repo": "lib-aggregate",
|
||||
"rev": "74c775886c8f89a0af4743a9144c5bbd04125725",
|
||||
"rev": "d03a5f88a345d26ca13918071d42dcc960233183",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
|
@ -563,11 +563,11 @@
|
|||
"lix": {
|
||||
"flake": false,
|
||||
"locked": {
|
||||
"lastModified": 1727623796,
|
||||
"narHash": "sha256-IsdPqCIc7eZwU9I1mO2huN0t1wUxgDKgmV4UeLv3elA=",
|
||||
"rev": "aa33c34c9be074c9452976aa96d71091325c83ea",
|
||||
"lastModified": 1727783747,
|
||||
"narHash": "sha256-fLiDo55WLgikMaaZcFEpkCkL4fQiV7RNEjRn+LxiYao=",
|
||||
"rev": "775292766025380d04004e42fefbdb8ca40b3fa3",
|
||||
"type": "tarball",
|
||||
"url": "https://git.lix.systems/api/v1/repos/lix-project/lix/archive/aa33c34c9be074c9452976aa96d71091325c83ea.tar.gz?rev=aa33c34c9be074c9452976aa96d71091325c83ea"
|
||||
"url": "https://git.lix.systems/api/v1/repos/lix-project/lix/archive/775292766025380d04004e42fefbdb8ca40b3fa3.tar.gz?rev=775292766025380d04004e42fefbdb8ca40b3fa3"
|
||||
},
|
||||
"original": {
|
||||
"type": "tarball",
|
||||
|
@ -586,11 +586,11 @@
|
|||
]
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1726631249,
|
||||
"narHash": "sha256-b2rMO8+jKjY55d8uynX7FjV4NIPu/WzPux0kWOAzwoo=",
|
||||
"rev": "b0e6f359500d66670cc16f521e4f62d6a0a4864e",
|
||||
"lastModified": 1727752861,
|
||||
"narHash": "sha256-jowmo2aEzrEpPSM96IWtajuogdJm7DjAWxFTEb7Ct0s=",
|
||||
"rev": "fd186f535a4ac7ae35d98c1dd5d79f0a81b7976d",
|
||||
"type": "tarball",
|
||||
"url": "https://git.lix.systems/api/v1/repos/lix-project/nixos-module/archive/b0e6f359500d66670cc16f521e4f62d6a0a4864e.tar.gz?rev=b0e6f359500d66670cc16f521e4f62d6a0a4864e"
|
||||
"url": "https://git.lix.systems/api/v1/repos/lix-project/nixos-module/archive/fd186f535a4ac7ae35d98c1dd5d79f0a81b7976d.tar.gz?rev=fd186f535a4ac7ae35d98c1dd5d79f0a81b7976d"
|
||||
},
|
||||
"original": {
|
||||
"type": "tarball",
|
||||
|
@ -845,11 +845,11 @@
|
|||
"nixpkgs": "nixpkgs_6"
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1727614831,
|
||||
"narHash": "sha256-ffvX/qhMqol1E7Rv+oRSVXxYgYvKy5bfZAyjYdq/9RI=",
|
||||
"lastModified": 1727710797,
|
||||
"narHash": "sha256-2Xr8tAZoLrMkvD0Sil6053x2Lbsy8cvmlk8sApSWdD0=",
|
||||
"owner": "nix-community",
|
||||
"repo": "nixpkgs-wayland",
|
||||
"rev": "206b2a2a8505b9e8afb5d1b5ffea2b574b7983b6",
|
||||
"rev": "50e4446e6dce9e1e52455f5b87bb91e83a538468",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
|
@ -892,11 +892,11 @@
|
|||
},
|
||||
"nixpkgs_4": {
|
||||
"locked": {
|
||||
"lastModified": 1727348695,
|
||||
"narHash": "sha256-J+PeFKSDV+pHL7ukkfpVzCOO7mBSrrpJ3svwBFABbhI=",
|
||||
"lastModified": 1727634051,
|
||||
"narHash": "sha256-S5kVU7U82LfpEukbn/ihcyNt2+EvG7Z5unsKW9H/yFA=",
|
||||
"owner": "nixos",
|
||||
"repo": "nixpkgs",
|
||||
"rev": "1925c603f17fc89f4c8f6bf6f631a802ad85d784",
|
||||
"rev": "06cf0e1da4208d3766d898b7fdab6513366d45b9",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
|
@ -1001,11 +1001,11 @@
|
|||
"rust-overlay": "rust-overlay"
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1727705464,
|
||||
"narHash": "sha256-AN+lqsNz64FXmi1bXwR4zj2Yl0j6ktGHQeE3VJsE1Ic=",
|
||||
"lastModified": 1727785014,
|
||||
"narHash": "sha256-u9R0Atlcy1Y+r63zk66rjOwMij30ZLwoo6l1k7+OI08=",
|
||||
"owner": "roc-lang",
|
||||
"repo": "roc",
|
||||
"rev": "775bce294b732dbdbeefed6d8d94516f13422210",
|
||||
"rev": "aaeefc09b60313a28597372d3fdec041c1b96a22",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
|
@ -1231,11 +1231,11 @@
|
|||
},
|
||||
"locked": {
|
||||
"dir": "nix",
|
||||
"lastModified": 1727369985,
|
||||
"narHash": "sha256-ywfXk25Z0dYDzxa+wlwcPlBIS+XusuQhZKcKdWsP+bw=",
|
||||
"lastModified": 1727738646,
|
||||
"narHash": "sha256-OlKbUvhtdgMBW/BvmA7TSAzbvR2AD+tGo9oaEXoS2MY=",
|
||||
"owner": "daylinmorgan",
|
||||
"repo": "tsm",
|
||||
"rev": "bd94042d38826754e9ac8e35b15d22c64121039a",
|
||||
"rev": "07dd5a5238e0ddc67b24772be7b1f742693b4535",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
|
|
|
@ -8,5 +8,5 @@ buildNimblePackage {
|
|||
verions = "unstable";
|
||||
src = lib.cleanSource ./.;
|
||||
nativeBuildInputs = [ openssl ];
|
||||
nimbleDepsHash = "sha256-A2sQy4x+QyqltV7B1rRh7uRPvv7pDtVNOXZZl5LrHCY=";
|
||||
nimbleDepsHash = "sha256-3p+PdGkQmKwz5tzJwX0aun3kSOLw/lwzqRkR9+6ECQE=";
|
||||
}
|
||||
|
|
|
@ -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": {
|
||||
|
|
|
@ -1,14 +1,11 @@
|
|||
## nix begat oizys
|
||||
import std/[os, tables, sequtils, strformat,strutils]
|
||||
|
||||
import hwylterm
|
||||
import hwylterm/cli
|
||||
import oizys/[context, github, nix, overlay, logging]
|
||||
import std/[os, tables, sequtils, strformat, strutils]
|
||||
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"
|
||||
)
|
||||
)
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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,
|
||||
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
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
Loading…
Reference in a new issue