Document the dynamic outputs

This commit is contained in:
Zahary Karadjov 2019-10-02 16:57:07 +03:00
parent 80aea4ee2a
commit a2ea339569
No known key found for this signature in database
GPG Key ID: C8936F8A3073D609
1 changed files with 13 additions and 0 deletions

View File

@ -497,6 +497,19 @@ the default automatically:
chronicles will add an index such as `.2.log`, `.3.log` .. `.N.log`
to the final file name.
## Working with `dynamic` outputs
A `dynamic` output redirects all logged messages to a closure supplied by
the host application. Similar to working with file ouputs [file outputs](#working-with-file-outputs),
you can use the `output` and `outputs` properties of a Chronicles stream
to specify a gcsafe closure:
```nim
defaultChroniclesStream.output.writer =
proc (logLevel: LogLevel, msg: LogOutputStr) {.gcsafe.} =
database.writeLogEntry(msg)
```
## Teaching Chronicles about your types
Chronicles can output log records in any of the formats supported by the Nim