https://github.com/flickpp/ndjsonlogger
https://github.com/flickpp/ndjsonlogger
Last synced: 11 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/flickpp/ndjsonlogger
- Owner: flickpp
- Created: 2022-07-16T13:54:46.000Z (almost 4 years ago)
- Default Branch: master
- Last Pushed: 2022-07-18T12:21:06.000Z (almost 4 years ago)
- Last Synced: 2025-06-09T00:13:02.770Z (12 months ago)
- Language: Rust
- Size: 16.6 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# ndjsonlogger
ndjsonlogger is an nd (newline delimited) json logger.
Rust 1.60 or greater is required.
## TODO/Features
- [x] debug, info, warn and error macros
- [x] debug! macro compiles to no-op on release builds
- [ ] trace macro with trace mask
- [x] all JSON primative types (number, bool, null) supported
- [x] one level of nested arrays
- [ ] `Option<&[_]>` and `&[Option<_>]`
- [x] compile-time iso timestamp feature
- [x] quickstart print log lines to stdout
- [ ] configurable alternative sinks for log lines
- [ ] initialize with service name - add to all log lines
- [ ] custom runtime logic for additional key/value(s)
- [ ] work with ndjsonloggercore `no_std`
## Quickstart
```toml
[dependencies]
ndjsonlogger = "0.1"
ndjsonloggercore = {version = "0.1", features = ["std"]}
```
NOTE: You must include BOTH lines in your Cargo.toml.
Additionally for the 0.1 release, the std feature is required in ndjsonloggercore.
```rust
use ndjsonlogger::{info, debug};
fn main() {
info!("hello I'm a log line");
debug!("application closing", {
reason = "end of main function"
});
}}
```
```json
{"level": "info", "msg": "hello I'm a log line"}
{"level": "debug", "msg": "application closing", "reason": "end of main function"}
```
An example demonstrating all features is [here](../master/example/src/main.rs).
## Contributing
Contributions welcome. Please open a github issue.