Skip to content

Commit

Permalink
Merge pull request #58 from xeptore/patch-1
Browse files Browse the repository at this point in the history
Improve documentation
  • Loading branch information
borntyping committed Mar 20, 2022
2 parents 02a1a1d + 8914cd0 commit c374d15
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 12 deletions.
12 changes: 6 additions & 6 deletions README.md
Expand Up @@ -28,44 +28,44 @@ fn main() {

This outputs:

```
```txt
2022-01-19T17:27:07.013874956Z WARN [logging_example] This is an example message.
```

You can run the above example with:

```bash
```sh
cargo run --example init
```

Coloured output and timestamps will be enabled by default. You can remove these
features and their respective dependencies by disabling all features in your
`Cargo.toml`.

```
```toml
[dependencies.simple_logger]
default-features = false
```

To include the `timestamps` feature, but not the `colors` feature:

```
```toml
[dependencies.simple_logger]
default-features = false
features = ["timestamps"]
```

To include the `colors` feature, but not the `timestamps` feature:

```
```toml
[dependencies.simple_logger]
default-features = false
features = ["colors"]
```

To direct logging output to `stderr` use the `stderr` feature:

```
```toml
[dependencies.simple_logger]
features = ["stderr"]
```
Expand Down
12 changes: 6 additions & 6 deletions src/lib.rs
Expand Up @@ -2,7 +2,7 @@
//!
//! Optional features include timestamps, colored output and logging to stderr.
//!
//! ```
//! ```rust
//! simple_logger::SimpleLogger::new().env().init().unwrap();
//!
//! log::warn!("This is an example message.");
Expand All @@ -12,19 +12,19 @@
//!
//! Just initialize logging without any configuration:
//!
//! ```
//! ```rust
//! simple_logger::init().unwrap();
//! ```
//!
//! Set the log level from the `RUST_LOG` environment variable:
//!
//! ```
//! ```rust
//! simple_logger::init_with_env().unwrap();
//! ```
//!
//! Hardcode a default log level:
//!
//! ```
//! ```rust
//! simple_logger::init_with_level(log::Level::Warn).unwrap();
//! ```

Expand Down Expand Up @@ -488,15 +488,15 @@ fn set_up_color_terminal() {
}
}

/// Initialise the logger with it's default configuration.
/// Initialise the logger with its default configuration.
///
/// Log messages will not be filtered.
/// The `RUST_LOG` environment variable is not used.
pub fn init() -> Result<(), SetLoggerError> {
SimpleLogger::new().init()
}

/// Initialise the logger with it's default configuration.
/// Initialise the logger with its default configuration.
///
/// Log messages will not be filtered.
/// The `RUST_LOG` environment variable is not used.
Expand Down

0 comments on commit c374d15

Please sign in to comment.