diff options
-rw-r--r-- | lib/pure/logging.nim | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/lib/pure/logging.nim b/lib/pure/logging.nim index 598ee01d3..e2a5bed96 100644 --- a/lib/pure/logging.nim +++ b/lib/pure/logging.nim @@ -153,8 +153,11 @@ method log*(logger: ConsoleLogger, level: Level, args: varargs[string, `$`]) = let cln: cstring = ln {.emit: "console.log(`cln`);".} else: - writeLine(stdout, ln) - if level in {lvlError, lvlFatal}: flushFile(stdout) + try: + writeLine(stdout, ln) + if level in {lvlError, lvlFatal}: flushFile(stdout) + except IOError: + discard proc newConsoleLogger*(levelThreshold = lvlAll, fmtStr = defaultFmtStr): ConsoleLogger = ## Creates a new console logger. This logger logs to the console. |