This repository was archived by the owner on Dec 7, 2024. It is now read-only.
Commit 0f83ff7 1 parent b0cd46c commit 0f83ff7 Copy full SHA for 0f83ff7
File tree 3 files changed +26
-6
lines changed
3 files changed +26
-6
lines changed Original file line number Diff line number Diff line change 1
1
[package ]
2
2
name = " dioxus-logger"
3
- version = " 0.4.0 "
3
+ version = " 0.4.1 "
4
4
edition = " 2021"
5
5
description = " A logging utility to provide a standard interface whether you're targetting web, desktop, or mobile."
6
6
repository = " https://github.com/DogeDark/dioxus-logger"
Original file line number Diff line number Diff line change 33
33
- [ ] Logging to a file
34
34
- [ ] Logging to [ Sentry] ( https://sentry.io/ ) ?
35
35
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
39
38
use dioxus :: prelude :: * ;
40
39
use log :: {info, LevelFilter };
41
40
@@ -60,6 +59,27 @@ You can add `dioxus-logger` to your application by adding it to your dependencie
60
59
dioxus-logger = " x.x.x"
61
60
```
62
61
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
+
63
83
## License
64
84
This project is licensed under the [ MIT license] .
65
85
Original file line number Diff line number Diff line change @@ -19,10 +19,10 @@ pub struct DioxusLogger {
19
19
impl DioxusLogger {
20
20
/// Create a new [`DioxusLogger`] struct to configure and build.
21
21
pub fn new ( level_filter : LevelFilter ) -> Self {
22
- let format = "[{LEVEL}] {PATH} - {ARGS}] " ;
22
+ let format = "[{LEVEL}] {PATH} - {ARGS}" ;
23
23
24
24
#[ cfg( feature = "timestamps" ) ]
25
- let format = "[{TIMESTAMP} | {LEVEL}] {PATH} - {ARGS}] " ;
25
+ let format = "[{TIMESTAMP} | {LEVEL}] {PATH} - {ARGS}" ;
26
26
27
27
Self {
28
28
level_filter,
You can’t perform that action at this time.
0 commit comments