Skip to content

Commit

Permalink
catchup
Browse files Browse the repository at this point in the history
Signed-off-by: tison <[email protected]>
  • Loading branch information
tisonkun committed Oct 28, 2024
1 parent e6390f9 commit 7c966c4
Show file tree
Hide file tree
Showing 8 changed files with 51 additions and 64 deletions.
29 changes: 10 additions & 19 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,32 +34,23 @@ cargo add logforth
Then, you can use the logger with the simplest default setup:

```rust
use log::LevelFilter;
use logforth::append;
use logforth::layout::TextLayout;
use logforth::Dispatch;
use logforth::Logger;

fn main() {
Logger::new().dispatch(
Dispatch::new()
.filter(LevelFilter::Trace)
.append(append::Stdout::default()),
)
.apply()
.unwrap();

log::error!("Hello error!");
log::warn!("Hello warn!");
log::info!("Hello info!");
log::debug!("Hello debug!");
log::trace!("Hello trace!");
logforth::stderr().finish();
}
```

Or configure the logger in a more fine-grained way:

```rust
fn main() {
logforth::builder()
.filter(log::LevelFilter::Debug)
.append(logforth::append::Stderr::default())
.dispatch()
.filter(log::LevelFilter::Info)
.append(logforth::append::Stdout::default())
.finish();
}
```

Read more demos under the [examples](examples) directory.
Expand Down
3 changes: 1 addition & 2 deletions examples/env_filter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,7 @@ fn main() {
logforth::builder()
.filter(EnvFilter::from_default_env())
.append(append::Stdout::default())
.finish()
.unwrap();
.finish();

log::error!("Hello error!");
log::warn!("Hello warn!");
Expand Down
4 changes: 2 additions & 2 deletions examples/fn_layout_filter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ fn main() {
Ok(format!("[system alert] {}", record.args()).into_bytes())
})),
)
.finish()
.unwrap();
.finish();

log::error!("Hello error!");
log::warn!("Hello warn!");
log::info!("Hello info!");
Expand Down
3 changes: 1 addition & 2 deletions examples/json_stdio.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,7 @@ use logforth::layout::JsonLayout;
fn main() {
logforth::builder()
.append(append::Stdout::default().with_layout(JsonLayout::default()))
.finish()
.unwrap();
.finish();

log::error!("Hello error!");
log::warn!("Hello warn!");
Expand Down
3 changes: 1 addition & 2 deletions examples/rolling_file.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,7 @@ fn main() {
.dispatch()
.filter("info")
.append(Stdout::default())
.finish()
.unwrap();
.finish();

let repeat = 1;

Expand Down
3 changes: 1 addition & 2 deletions examples/simple_stdio.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,7 @@ fn main() {
.filter(LevelFilter::Trace)
.append(append::Stdout::default())
.append(append::Stderr::default())
.finish()
.unwrap();
.finish();

log::error!("Hello error!");
log::warn!("Hello warn!");
Expand Down
67 changes: 34 additions & 33 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,39 +12,40 @@
// See the License for the specific language governing permissions and
// limitations under the License.

//! # A versatile and extensible logging implementation
//!
//! ## Usage
//!
//! Add the dependencies to your `Cargo.toml` with:
//!
//! ```shell
//! cargo add log
//! cargo add logforth
//! ```
//!
//! Here, [`log`] is the logging facade and `logforth` is the logging implementation.
//!
//! Then, you can use the logger with:
//!
//! ```rust
//! use log::LevelFilter;
//! use logforth::append;
//!
//! logforth::builder()
//! .filter(LevelFilter::Info)
//! .append(append::Stdout::default())
//! .finish()
//! .unwrap();
//!
//! log::error!("Hello error!");
//! log::warn!("Hello warn!");
//! log::info!("Hello info!");
//! log::debug!("Hello debug!");
//! log::trace!("Hello trace!");
//! ```
//!
//! Read more demos under the [examples](https://github.com/fast/logforth/tree/main/examples) directory.
/*!
# A versatile and extensible logging implementation
## Usage
Add the dependencies to your `Cargo.toml` with:
```shell
cargo add log
cargo add logforth
```
[`log`] is the logging facade and `logforth` is the logging implementation.
Then, you can use the logger with the simplest default setup:
```rust
logforth::stderr().finish();
```
Or configure the logger in a more fine-grained way:
```rust
logforth::builder()
.filter(log::LevelFilter::Debug)
.append(logforth::append::Stderr::default())
.dispatch()
.filter(log::LevelFilter::Info)
.append(logforth::append::Stdout::default())
.finish();
```
Read more demos under the [examples](https://github.com/fast/logforth/tree/main/examples) directory.
*/

#![cfg_attr(docsrs, feature(doc_auto_cfg))]

Expand Down
3 changes: 1 addition & 2 deletions tests/recursive_logging.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,7 @@ fn test_meta_logging_in_format_works() {
.append(append::Stderr::default().with_layout(layout("err")))
.dispatch()
.append(append::RollingFile::new(writer).with_layout(layout("file")))
.finish()
.unwrap();
.finish();

struct Thing<'a>(&'a str);

Expand Down

0 comments on commit 7c966c4

Please sign in to comment.