Skip to content
This repository was archived by the owner on Dec 7, 2024. It is now read-only.

Commit 0f83ff7

Browse files
committed
revision: readme
1 parent b0cd46c commit 0f83ff7

File tree

3 files changed

+26
-6
lines changed

3 files changed

+26
-6
lines changed

Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "dioxus-logger"
3-
version = "0.4.0"
3+
version = "0.4.1"
44
edition = "2021"
55
description = "A logging utility to provide a standard interface whether you're targetting web, desktop, or mobile."
66
repository = "https://github.com/DogeDark/dioxus-logger"

README.md

+23-3
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,8 @@
3333
- [ ] Logging to a file
3434
- [ ] Logging to [Sentry](https://sentry.io/)?
3535

36-
**This library is under development. Expect breaking changes.**
37-
38-
```rust, ignore
36+
**This library is not finished. Breaking changes may occur.**
37+
```rust
3938
use dioxus::prelude::*;
4039
use log::{info, LevelFilter};
4140

@@ -60,6 +59,27 @@ You can add `dioxus-logger` to your application by adding it to your dependencie
6059
dioxus-logger = "x.x.x"
6160
```
6261

62+
To use dioxus-logger as is, add this line before launching Dioxus, replacing ``LevelFilter::Info`` with your preferred log level.
63+
```rs
64+
dioxus_logger::init(LevelFilter::Info).expect("failed to init logger");
65+
```
66+
67+
## Custom Format
68+
Initialize dioxus-logger using the builder:
69+
```rs
70+
dioxus_logger::DioxusLogger::new(LevelFilter::Info)
71+
.use_format("[{LEVEL}] {PATH} - {ARGS}")
72+
.build()
73+
.expect("failed to init logger");
74+
```
75+
The available options for ``use_format`` are:
76+
- LEVEL - The log severity.
77+
- PATH - Which crate emitted the log.
78+
- ARGS - The text that was logged.
79+
- TIMESTAMP - A timestamp of when the log was emitted. Requires the ``timestamps`` feature.
80+
81+
Surround the option with ``{}`` in the ``use_format`` method.
82+
6383
## License
6484
This project is licensed under the [MIT license].
6585

src/lib.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,10 @@ pub struct DioxusLogger {
1919
impl DioxusLogger {
2020
/// Create a new [`DioxusLogger`] struct to configure and build.
2121
pub fn new(level_filter: LevelFilter) -> Self {
22-
let format = "[{LEVEL}] {PATH} - {ARGS}]";
22+
let format = "[{LEVEL}] {PATH} - {ARGS}";
2323

2424
#[cfg(feature = "timestamps")]
25-
let format = "[{TIMESTAMP} | {LEVEL}] {PATH} - {ARGS}]";
25+
let format = "[{TIMESTAMP} | {LEVEL}] {PATH} - {ARGS}";
2626

2727
Self {
2828
level_filter,

0 commit comments

Comments
 (0)