This repository was archived by the owner on Dec 7, 2024. It is now read-only.
File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11[package ]
22name = " dioxus-logger"
3- version = " 0.4.0 "
3+ version = " 0.4.1 "
44edition = " 2021"
55description = " A logging utility to provide a standard interface whether you're targetting web, desktop, or mobile."
66repository = " https://github.com/DogeDark/dioxus-logger"
Original file line number Diff line number Diff line change 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
3938use dioxus :: prelude :: * ;
4039use log :: {info, LevelFilter };
4140
@@ -60,6 +59,27 @@ You can add `dioxus-logger` to your application by adding it to your dependencie
6059dioxus-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
6484This project is licensed under the [ MIT license] .
6585
Original file line number Diff line number Diff line change @@ -19,10 +19,10 @@ pub struct DioxusLogger {
1919impl 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,
You can’t perform that action at this time.
0 commit comments