diff --git a/chronicles/topics_registry.nim b/chronicles/topics_registry.nim index 159cea2..d9f6451 100644 --- a/chronicles/topics_registry.nim +++ b/chronicles/topics_registry.nim @@ -1,4 +1,4 @@ -import locks, macros, tables +import locks, macros, tables, strutils from options import LogLevel export @@ -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 diff --git a/tests/runtime_filtering.nim b/tests/runtime_filtering.nim index 4f7944e..44f8a87 100644 --- a/tests/runtime_filtering.nim +++ b/tests/runtime_filtering.nim @@ -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()