2 Commits

Author SHA1 Message Date
2f761833bd Use message for structures message contents, not msg.
I like `msg`, but `message` is more common and likely to the more
expected name.
2025-07-06 04:12:47 -05:00
c4074007b5 Tweaks to README intro. 2025-07-06 04:12:23 -05:00
2 changed files with 11 additions and 9 deletions

View File

@@ -1,21 +1,22 @@
# Namespaced Logging for Nim
`namespaced_logging` provides a high-performance, thread-safe logging framework
similar to [std/logging][std-logging] with support for namespace-scoped logging
similar to [log4j][] or [logback][] for Nim. It has four main motivating
features:
`namespaced_logging` is intended to be a high-performance, thread-safe logging
framework similar to [std/logging][std-logging] with support for
namespace-scoped logging similar to [log4j][] or [logback][] for Nim. It has
four main motivating features:
- Hierarchical, namespaced logging
- Safe and straightforward to use in multi-threaded applications.
- Native support for structured logging.
- Simple, autoconfigured usage pattern mirroring the [std/logging][std-logging]
interface.
- Simple, autoconfigured usage pattern reminiscent of the
[std/logging][std-logging] interface.
## Getting Started
Install the package from nimble:
Install the package via nimble:
```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
@@ -92,6 +93,7 @@ proc createApiRouter*(apiCtx: ProbatemApiContext): Router =
let server = newServer(createApiRouter(), workerThreads = 4)
ctx.server.serve(Port(8080))
info("Serving MyApp v1.0.0 on port 8080")
setThreshold("api", lvlTrace) # will be picked up by loggers on worker threads

View File

@@ -440,7 +440,7 @@ proc log*(l: Logger, lvl: Level, msg: JsonNode) {.gcsafe.} =
error: none[ref Exception](),
timestamp: now(),
message:
if msg.hasKey("msg"): msg["msg"].getStr
if msg.hasKey("message"): msg["message"].getStr
else: "",
additionalData: msg))