Skip to content

Commit

Permalink
Merge pull request #35 from baoyachi/issue/34
Browse files Browse the repository at this point in the history
Add target feature example
  • Loading branch information
baoyachi authored Aug 20, 2024
2 parents 06f4e17 + 1ece5bc commit 1192283
Show file tree
Hide file tree
Showing 4 changed files with 53 additions and 7 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/rust.yml
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ jobs:
- name: Test
run: |
cargo test --all-features
cargo test --examples
cargo test --examples --all-features
- name: Coverage
if: matrix.rust == 'stable'
run: cargo tarpaulin -o Lcov --output-dir ./coverage
Expand Down
9 changes: 7 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[workspace.package]
version = "1.7.0"
version = "1.7.1"
edition = "2021"
authors = ["baoyachi <[email protected]>"]
description = "A simple log. It's really simple use"
Expand Down Expand Up @@ -36,7 +36,7 @@ convert_case = "0.6.0"
[dependencies.simple-log-derive]
path = "simple-log-derive"
optional = true
version = "1.7.0"
version = "1"

[dev-dependencies]
serde_json = "1"
Expand All @@ -49,3 +49,8 @@ members = ["./", "simple-log-derive"]

[features]
target = ["simple-log-derive"]

[[example]]
name = "target"
path = "examples/target.rs"
required-features = ["target"]
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ A simple-log with local file or stdout write by Rust.
## Quick Use
```toml
[dependencies]
simple-log = "1.5.1"
simple-log = "{latest}"
```

```rust
Expand All @@ -37,7 +37,7 @@ fn main() {
## Usage in project
```toml
[dependencies]
simple-log = "1.5.1"
simple-log = "{latest}"
```
```rust
#[macro_use]
Expand Down Expand Up @@ -66,7 +66,7 @@ fn main() -> Result<(), String> {
## Config with toml
```toml
[dependencies]
simple-log = "1.5.1"
simple-log = "{latest}"
toml = "0.5.7"
```

Expand Down Expand Up @@ -108,7 +108,7 @@ fn main() {

```toml
[dependencies]
simple-log = "1.5.1"
simple-log = "{latest}"
serde_json = "1"
```

Expand Down
41 changes: 41 additions & 0 deletions examples/target.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
//! `cargo run --example console`
//!
//! With OutPut
//! ```bash
//! 2024-08-20 15:43:09.309146000 [TRACE] [ctrl] <examples/target.rs:18>:test target trace
//! 2024-08-20 15:43:09.309336000 [TRACE] [parser] <examples/target.rs:19>:test target trace
//! 2024-08-20 15:43:09.309345000 [DEBUG] [target] <examples/target.rs:21>:test target debug
//! 2024-08-20 15:43:09.309352000 [DEBUG] [ctrl] <examples/target.rs:22>:test target debug
//! 2024-08-20 15:43:09.309358000 [DEBUG] [parser] <examples/target.rs:23>:test target debug
//! 2024-08-20 15:43:09.309364000 [INFO] [target] <examples/target.rs:25>:test target info
//! 2024-08-20 15:43:09.309371000 [INFO] [ctrl] <examples/target.rs:26>:test target info
//! 2024-08-20 15:43:09.309377000 [INFO] [parser] <examples/target.rs:27>:test target info
//! 2024-08-20 15:43:09.309383000 [WARN] [target] <examples/target.rs:29>:test target warn
//! 2024-08-20 15:43:09.309389000 [ERROR] [target] <examples/target.rs:30>:test target error
//! ```

#[macro_use]
extern crate simple_log;

fn main() -> Result<(), String> {
simple_log::console("trace")?;

simple_log::log_target!(ctrl);
simple_log::log_target!(parser);

trace_ctrl!("test target trace");
trace_parser!("test target trace");

debug!("test target debug");
debug_ctrl!("test target debug");
debug_parser!("test target debug");

info!("test target info");
info_ctrl!("test target info");
info_parser!("test target info");

warn!("test target warn");
error!("test target error");

Ok(())
}

0 comments on commit 1192283

Please sign in to comment.