Compare commits
2 Commits
05f5c2548c
...
2f761833bd
Author | SHA1 | Date | |
---|---|---|---|
2f761833bd | |||
c4074007b5 |
18
README.md
18
README.md
@@ -1,21 +1,22 @@
|
|||||||
# Namespaced Logging for Nim
|
# Namespaced Logging for Nim
|
||||||
|
|
||||||
`namespaced_logging` provides a high-performance, thread-safe logging framework
|
`namespaced_logging` is intended to be a high-performance, thread-safe logging
|
||||||
similar to [std/logging][std-logging] with support for namespace-scoped logging
|
framework similar to [std/logging][std-logging] with support for
|
||||||
similar to [log4j][] or [logback][] for Nim. It has four main motivating
|
namespace-scoped logging similar to [log4j][] or [logback][] for Nim. It has
|
||||||
features:
|
four main motivating features:
|
||||||
- Hierarchical, namespaced logging
|
- Hierarchical, namespaced logging
|
||||||
- Safe and straightforward to use in multi-threaded applications.
|
- Safe and straightforward to use in multi-threaded applications.
|
||||||
- Native support for structured logging.
|
- Native support for structured logging.
|
||||||
- Simple, autoconfigured usage pattern mirroring the [std/logging][std-logging]
|
- Simple, autoconfigured usage pattern reminiscent of the
|
||||||
interface.
|
[std/logging][std-logging] interface.
|
||||||
|
|
||||||
## Getting Started
|
## Getting Started
|
||||||
|
|
||||||
Install the package from nimble:
|
Install the package via nimble:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
nimble install namespaced_logging
|
# Not yet in official Nim packages. TODO once we've battle-tested it a little
|
||||||
|
nimble install https://github.com/jdbernard/nim-namespaced-logging
|
||||||
```
|
```
|
||||||
|
|
||||||
## Usage Patterns
|
## Usage Patterns
|
||||||
@@ -92,6 +93,7 @@ proc createApiRouter*(apiCtx: ProbatemApiContext): Router =
|
|||||||
|
|
||||||
|
|
||||||
let server = newServer(createApiRouter(), workerThreads = 4)
|
let server = newServer(createApiRouter(), workerThreads = 4)
|
||||||
|
ctx.server.serve(Port(8080))
|
||||||
info("Serving MyApp v1.0.0 on port 8080")
|
info("Serving MyApp v1.0.0 on port 8080")
|
||||||
|
|
||||||
setThreshold("api", lvlTrace) # will be picked up by loggers on worker threads
|
setThreshold("api", lvlTrace) # will be picked up by loggers on worker threads
|
||||||
|
@@ -440,7 +440,7 @@ proc log*(l: Logger, lvl: Level, msg: JsonNode) {.gcsafe.} =
|
|||||||
error: none[ref Exception](),
|
error: none[ref Exception](),
|
||||||
timestamp: now(),
|
timestamp: now(),
|
||||||
message:
|
message:
|
||||||
if msg.hasKey("msg"): msg["msg"].getStr
|
if msg.hasKey("message"): msg["message"].getStr
|
||||||
else: "",
|
else: "",
|
||||||
additionalData: msg))
|
additionalData: msg))
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user