mirror of
https://github.com/ratatui/ratatui.git
synced 2026-04-19 21:26:43 +00:00
docs(examples): move tracing example to examples folder (#1658)
This commit is contained in:
28
Cargo.lock
generated
28
Cargo.lock
generated
@@ -1357,7 +1357,7 @@ dependencies = [
|
||||
"socket2",
|
||||
"tokio",
|
||||
"tower-service",
|
||||
"tracing",
|
||||
"tracing 0.1.41",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -2024,7 +2024,7 @@ dependencies = [
|
||||
"tokio",
|
||||
"tower",
|
||||
"tower-http",
|
||||
"tracing",
|
||||
"tracing 0.1.41",
|
||||
"url",
|
||||
"web-time",
|
||||
]
|
||||
@@ -2579,7 +2579,7 @@ dependencies = [
|
||||
"serde_json",
|
||||
"time",
|
||||
"tokio",
|
||||
"tracing",
|
||||
"tracing 0.1.41",
|
||||
"tracing-appender",
|
||||
"tracing-subscriber",
|
||||
"unicode-width",
|
||||
@@ -3630,7 +3630,7 @@ dependencies = [
|
||||
"tokio-util",
|
||||
"tower-layer",
|
||||
"tower-service",
|
||||
"tracing",
|
||||
"tracing 0.1.41",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -3649,7 +3649,7 @@ dependencies = [
|
||||
"tower",
|
||||
"tower-layer",
|
||||
"tower-service",
|
||||
"tracing",
|
||||
"tracing 0.1.41",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -3664,6 +3664,18 @@ version = "0.3.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "8df9b6e13f2d32c91b9bd719c00d1958837bc7dec474d94952798cc8e69eeec3"
|
||||
|
||||
[[package]]
|
||||
name = "tracing"
|
||||
version = "0.0.0"
|
||||
dependencies = [
|
||||
"color-eyre",
|
||||
"crossterm",
|
||||
"ratatui",
|
||||
"tracing 0.1.41",
|
||||
"tracing-appender",
|
||||
"tracing-subscriber",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "tracing"
|
||||
version = "0.1.41"
|
||||
@@ -3715,7 +3727,7 @@ version = "0.2.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "8b1581020d7a273442f5b45074a6a57d5757ad0a47dac0e9f0bd57b81936f3db"
|
||||
dependencies = [
|
||||
"tracing",
|
||||
"tracing 0.1.41",
|
||||
"tracing-subscriber",
|
||||
]
|
||||
|
||||
@@ -3743,7 +3755,7 @@ dependencies = [
|
||||
"sharded-slab",
|
||||
"smallvec",
|
||||
"thread_local",
|
||||
"tracing",
|
||||
"tracing 0.1.41",
|
||||
"tracing-core",
|
||||
"tracing-log",
|
||||
]
|
||||
@@ -4245,7 +4257,7 @@ dependencies = [
|
||||
"color-eyre",
|
||||
"duct",
|
||||
"itertools 0.13.0",
|
||||
"tracing",
|
||||
"tracing 0.1.41",
|
||||
"tracing-subscriber",
|
||||
]
|
||||
|
||||
|
||||
@@ -126,6 +126,10 @@ Shows how to handle panics in your application. [Source](./apps/panic/).
|
||||
|
||||
Shows how to handle popups. [Source](./apps/popup/).
|
||||
|
||||
## Tracing demo
|
||||
|
||||
Shows how to use the [tracing](https://crates.io/crates/tracing) crate to log to a file. [Source](./apps/tracing/).
|
||||
|
||||
## Weather demo
|
||||
|
||||
Shows how to render weather data using barchart widget. [Source](./apps/weather/).
|
||||
|
||||
17
examples/apps/tracing/Cargo.toml
Normal file
17
examples/apps/tracing/Cargo.toml
Normal file
@@ -0,0 +1,17 @@
|
||||
[package]
|
||||
name = "tracing"
|
||||
publish = false
|
||||
license.workspace = true
|
||||
edition.workspace = true
|
||||
rust-version.workspace = true
|
||||
|
||||
[dependencies]
|
||||
color-eyre.workspace = true
|
||||
crossterm.workspace = true
|
||||
ratatui.workspace = true
|
||||
tracing = "0.1.40"
|
||||
tracing-appender = "0.2.3"
|
||||
tracing-subscriber = { version = "0.3.18", features = ["env-filter"] }
|
||||
|
||||
[lints]
|
||||
workspace = true
|
||||
9
examples/apps/tracing/README.md
Normal file
9
examples/apps/tracing/README.md
Normal file
@@ -0,0 +1,9 @@
|
||||
# Tracing demo
|
||||
|
||||
This example demonstrates how to use the [tracing](https://crates.io/crates/tracing) crate to log to a file.
|
||||
|
||||
To run this demo:
|
||||
|
||||
```shell
|
||||
cargo run -p tracing
|
||||
```
|
||||
@@ -1,32 +1,23 @@
|
||||
//! # [Ratatui] Tracing example
|
||||
//!
|
||||
//! The latest version of this example is available in the [examples] folder in the repository.
|
||||
//!
|
||||
//! Please note that the examples are designed to be run against the `main` branch of the Github
|
||||
//! repository. This means that you may not be able to compile with the latest release version on
|
||||
//! crates.io, or the one that you have installed locally.
|
||||
//!
|
||||
//! See the [examples readme] for more information on finding examples that match the version of the
|
||||
//! library you are using.
|
||||
//!
|
||||
//! [Ratatui]: https://github.com/ratatui/ratatui
|
||||
//! [examples]: https://github.com/ratatui/ratatui/blob/main/examples
|
||||
//! [examples readme]: https://github.com/ratatui/ratatui/blob/main/examples/README.md
|
||||
|
||||
// A simple example demonstrating how to use the [tracing] with Ratatui to log to a file.
|
||||
//
|
||||
// This example demonstrates how to use the [tracing] crate with Ratatui to log to a file. The
|
||||
// example sets up a simple logger that logs to a file named `tracing.log` in the current directory.
|
||||
//
|
||||
// Run the example with `cargo run --example tracing` and then view the `tracing.log` file to see
|
||||
// the logs. To see more logs, you can run the example with `RUST_LOG=tracing=debug cargo run
|
||||
// --example`
|
||||
//
|
||||
// For a helpful widget that handles logging, see the [tui-logger] crate.
|
||||
//
|
||||
// [tracing]: https://crates.io/crates/tracing
|
||||
// [tui-logger]: https://crates.io/crates/tui-logger
|
||||
|
||||
/// A simple example demonstrating how to use the [tracing] with Ratatui to log to a file.
|
||||
///
|
||||
/// This example demonstrates how to use the [tracing] crate with Ratatui to log to a file. The
|
||||
/// example sets up a simple logger that logs to a file named `tracing.log` in the current
|
||||
/// directory.
|
||||
///
|
||||
/// Run the example with `cargo run --example tracing` and then view the `tracing.log` file to
|
||||
/// see the logs. To see more logs, you can run the example with `RUST_LOG=tracing=debug cargo
|
||||
/// run --example`
|
||||
///
|
||||
/// For a helpful widget that handles logging, see the [tui-logger] crate.
|
||||
///
|
||||
/// [tracing]: https://crates.io/crates/tracing
|
||||
/// [tui-logger]: https://crates.io/crates/tui-logger
|
||||
///
|
||||
/// This example runs with the Ratatui library code in the branch that you are currently
|
||||
/// reading. See the [`latest`] branch for the code which works with the most recent Ratatui
|
||||
/// release.
|
||||
///
|
||||
/// [`latest`]: https://github.com/ratatui/ratatui/tree/latest
|
||||
use std::{fs::File, time::Duration};
|
||||
|
||||
use color_eyre::{eyre::Context, Result};
|
||||
@@ -157,11 +157,6 @@ name = "table-widget"
|
||||
required-features = ["crossterm"]
|
||||
doc-scrape-examples = true
|
||||
|
||||
[[example]]
|
||||
name = "tracing"
|
||||
required-features = ["crossterm"]
|
||||
doc-scrape-examples = true
|
||||
|
||||
[[example]]
|
||||
name = "user_input"
|
||||
required-features = ["crossterm"]
|
||||
|
||||
Reference in New Issue
Block a user