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>
This commit is contained in:
parent
af27e6bdea
commit
21b3ca636f
2 changed files with 11 additions and 3 deletions
|
|
@ -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>`_.
|
||||
##
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue