Add note to readme and a test case

This commit is contained in:
Zed 2020-03-06 21:39:05 +01:00 committed by zah
parent bd2edb8e86
commit e4de3a9001
3 changed files with 22 additions and 0 deletions

View File

@ -510,6 +510,13 @@ defaultChroniclesStream.output.writer =
database.writeLogEntry(msg)
```
## Using Chronicles with `{.noSideEffect.}`
Usage of Chronicles from `noSideEffect` procs (or `func`) is limited to the
`trace` statement. Normal logging can be considered a side effect, but `trace`
is meant as a debugging aid. It's analogous to Nim's `debugEcho`, which also
bypasses the effect system.
## Teaching Chronicles about your types
Chronicles can output log records in any of the formats supported by the Nim

View File

@ -0,0 +1,9 @@
program=no_side_effect
chronicles_sinks="textlines[stdout]"
chronicles_colors=None
chronicles_timestamps=None
chronicles_log_level=TRACE
[Output]
stdout="""TRC effect-free tid=0
"""

6
tests/no_side_effect.nim Normal file
View File

@ -0,0 +1,6 @@
import chronicles
func main =
trace "effect-free"
main()