Skip to content

Commit

Permalink
3.0.1
Browse files Browse the repository at this point in the history
  • Loading branch information
disruptek committed Jan 7, 2023
1 parent 5e99feb commit 00aec36
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 8 deletions.
20 changes: 13 additions & 7 deletions cutelog.nim
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,12 @@ method log*(logger: CuteConsoleLogger; level: Level; args: varargs[string, `$`])
prefix = logger.prefixer(level)
palette = logger.painter(level)

template output: untyped =
if logger.useStderr:
stderr
else:
stdmsg()

var
arguments: seq[string]
for a in args:
Expand All @@ -108,21 +114,21 @@ method log*(logger: CuteConsoleLogger; level: Level; args: varargs[string, `$`])
template ttyWrap(logic: untyped): untyped {.dirty.} =
## setting/resetting terminal styling as necessary
noclobber: # use the lock around output
if stdmsg.isatty:
stdmsg.resetAttributes
stdmsg.setForegroundColor(palette.fg,
if output.isatty:
output.resetAttributes
output.setForegroundColor(palette.fg,
bright = styleBright in palette.style)
stdmsg.setBackgroundColor(palette.bg,
output.setBackgroundColor(palette.bg,
bright = false)
stdmsg.setStyle(palette.style)
output.setStyle(palette.style)
logic
stdmsg.resetAttributes()
output.resetAttributes()
else:
logic

ttyWrap:
# separate logging arguments with spaces for convenience
stdmsg.writeLine(prefix & ln)
output.writeLine(prefix & ln)

proc newCuteLogger*(console: ConsoleLogger): CuteLogger =
## create a new logger instance which forwards to the given console logger
Expand Down
2 changes: 1 addition & 1 deletion cutelog.nimble
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
version = "3.0.0"
version = "3.0.1"
author = "disruptek"
description = "cute logging"
license = "MIT"
Expand Down

0 comments on commit 00aec36

Please sign in to comment.