diff options
author | Juan Carlos <juancarlospaco@gmail.com> | 2020-07-06 05:00:25 -0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-07-06 04:00:25 -0400 |
commit | 21b3ca636fa7eee53911ab134afe2805fd0bf47e (patch) | |
tree | 95df9cb7b51f8cae2c0acd85a3dea2f118832af6 /lib/pure/logging.nim | |
parent | af27e6bdea63bbf66718193ec44bc61e745ded38 (diff) | |
download | Nim-21b3ca636fa7eee53911ab134afe2805fd0bf47e.tar.gz |
Fix logging tiny bug (#14910)
* Fix logging tiny bug * Update changelog.md Co-authored-by: Danil Yarantsev <tiberiumk12@gmail.com> * Update changelog.md Co-authored-by: Danil Yarantsev <tiberiumk12@gmail.com> * Update changelog.md Co-authored-by: Danil Yarantsev <tiberiumk12@gmail.com> * https://github.com/nim-lang/Nim/pull/14910#discussion_r450012032 Co-authored-by: Danil Yarantsev <tiberiumk12@gmail.com>
Diffstat (limited to 'lib/pure/logging.nim')
-rw-r--r-- | lib/pure/logging.nim | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/lib/pure/logging.nim b/lib/pure/logging.nim index 2637fdf9d..2e79cd3ca 100644 --- a/lib/pure/logging.nim +++ b/lib/pure/logging.nim @@ -364,7 +364,12 @@ method log*(logger: ConsoleLogger, level: Level, args: varargs[string, `$`]) = let ln = substituteLog(logger.fmtStr, level, args) when defined(js): let cln: cstring = ln - {.emit: "console.log(`cln`);".} + case level + of lvlDebug: {.emit: "console.debug(`cln`);".} + of lvlInfo: {.emit: "console.info(`cln`);".} + of lvlWarn: {.emit: "console.warn(`cln`);".} + of lvlError: {.emit: "console.error(`cln`);".} + else: {.emit: "console.log(`cln`);".} else: try: var handle = stdout @@ -504,7 +509,6 @@ when not defined(js): # ------ proc countLogLines(logger: RollingFileLogger): int = - result = 0 let fp = open(logger.baseName, fmRead) for line in fp.lines(): result.inc() @@ -531,7 +535,7 @@ when not defined(js): mode: FileMode = fmReadWrite, levelThreshold = lvlAll, fmtStr = defaultFmtStr, - maxLines = 1000, + maxLines: Positive = 1000, bufSize: int = -1): RollingFileLogger = ## Creates a new `RollingFileLogger<#RollingFileLogger>`_. ## |