Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion chronicles/topics_registry.nim
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import locks, macros, tables
import locks, macros, tables, strutils
from options import LogLevel

export
Expand Down Expand Up @@ -40,6 +40,10 @@ proc setLogLevel*(lvl: LogLevel) =
lockRegistry:
gActiveLogLevel = lvl

proc setLogLevel*(lvl: string) =
lockRegistry:
gActiveLogLevel = parseEnum[LogLevel](lvl.toUpperAscii)

proc clearTopicsRegistry* =
lockRegistry:
gTotalEnabledTopics = 0
Expand Down
9 changes: 9 additions & 0 deletions tests/runtime_filtering.nim
Original file line number Diff line number Diff line change
Expand Up @@ -86,3 +86,12 @@ echo setTopicState("bar", Normal)

foo()
bar()

echo "> set global LogLevel to string warn, set main and foo to INFO, both should print:"
setLogLevel("warn")
echo setTopicState("main", Normal, INFO)
echo setTopicState("foo", Normal, INFO)
echo setTopicState("bar", Normal)

foo()
bar()