https://github.com/nymphium/nloge
Logger with eio
https://github.com/nymphium/nloge
algebraic-effects logger ocaml
Last synced: 7 months ago
JSON representation
Logger with eio
- Host: GitHub
- URL: https://github.com/nymphium/nloge
- Owner: Nymphium
- License: mit
- Created: 2023-04-29T14:15:48.000Z (over 2 years ago)
- Default Branch: develop
- Last Pushed: 2025-05-07T18:47:59.000Z (8 months ago)
- Last Synced: 2025-06-05T22:09:20.096Z (7 months ago)
- Topics: algebraic-effects, logger, ocaml
- Language: OCaml
- Homepage: https://nymphium.github.io/nloge/nloge
- Size: 387 KB
- Stars: 7
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG
- License: LICENSE
Awesome Lists containing this project
README
n log e
===
Nloge, no-blocking logger with [eio](https://github.com/ocaml-multicore/eio)
Logger emits JSON -{`Emit`} -> converts JSON to string -{`Write`}-> "log"s the string
# Usage
See [hello](/examples/hello.ml)
```ocaml
let () =
Eio_main.run
@@ fun env ->
Eio.Switch.run
@@ fun sw ->
Nloge.run ~sw ~outputs:[ env#stdout ] ~level:`Debug
@@ fun () ->
Nloge.debug
~__LOC__
~metadata:[ "now_posix", `Float (Eio.Time.now env#clock) ]
(fun m -> m "hello")
;;
```
By default nloge logs with JSON format:
```
$ dune exec --display=quiet examples/hello.exe
{"log_level":"DEBUG","message":"hello","label":"File \"examples/hello.ml\", line 9, characters 5-12","now_posix":1683056241.957986}
```
# custom writere
See [custom writer](/examples/custom_transformer.ml)
# LICENSE
MIT