Skip to content

Commit

Permalink
docs: update readme.md and module docs
Browse files Browse the repository at this point in the history
  • Loading branch information
cmackenzie1 committed Oct 8, 2023
1 parent 2794f38 commit d78d21e
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 1 deletion.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,4 +45,4 @@ See the [examples](./examples) directory for more examples.

## License

Licensed under MIT license ([LICENSE](LICENSE) or http://opensource.org/licenses/MIT)
Licensed under [MIT license](./LICENSE)
42 changes: 42 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,45 @@
//! # tracing-ndjson
//!
//! [![Rust](https://github.com/cmackenzie1/tracing-ndjson/actions/workflows/rust.yml/badge.svg)](https://github.com/cmackenzie1/tracing-ndjson/actions/workflows/rust.yml)
//!
//! A simple library for tracing in new-line delimited JSON format. This library is meant to be used with [tracing](https://github.com/tokio-rs/tracing) as an alternative to the `tracing_subscriber::fmt::json` formatter.
//!
//! ## Features
//!
//! - Configurable field names for `target`, `message`, `level`, and `timestamp`.
//! - Configurable timestamp formats such as RFC3339, UNIX timestamp, or any custom chrono format.
//! - Captures all span attributes and event fields in the root of the JSON object.
//!
//! ## Usage
//!
//! Add this to your `Cargo.toml`:
//!
//! ```toml
//! [dependencies]
//! tracing = "0.1"
//! tracing-ndjson = "0.1"
//! ```
//!
//! ```rust
//! tracing_subscriber::registry()
//! .with(tracing_ndjson::builder().layer())
//! .init();
//! tracing::info!(life = 42, "Hello, world!");
//! // {"level":"info","timestamp":"2023-10-08T03:30:52Z","target":"default","message":"Hello, world!"}
//! let span = tracing::info_span!("hello", "request.uri" = "https://example.com");
//! span.in_scope(|| {
//! tracing::info!("Hello, world!");
//! // {"level":"info","timestamp":"2023-10-08T03:34:33Z","target":"defaults","message":"Hello, world!","request.uri":"https://example.com"}
//! });
//! ```
//!
//! ### Examples
//!
//! See the [examples](./examples) directory for more examples.
//!
//! ## License
//!
//! Licensed under MIT license [LICENSE](./LICENSE)
mod formatter;

use tracing_core::Subscriber;
Expand Down

0 comments on commit d78d21e

Please sign in to comment.