-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Replace chrono-tz with time-tz and improve Time Zone selection (#99)
This PR updates the DateTime converter implementation to use the [time-tz crate](https://github.com/Yuri6037/time-tz) instead of chrono-tz. This patches https://github.com/esimkowitz/dev-widgets/security/dependabot/1. It also adds functionality to get the local timezone for the target system. The specific revision of this crate used here includes a proposed change I have added which extends support for getting the local time zone to WASM targets (Yuri6037/time-tz#14). This PR also adds support for logging, replacing use of println! in the application logic. This way, support for logging will be equal for both WASM and desktop targets. It also removes an unnecessary direct clap dependency.
- Loading branch information
1 parent
941f145
commit 865a5b8
Showing
6 changed files
with
215 additions
and
91 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
use log::*; | ||
|
||
#[cfg(not(target_family = "wasm"))] | ||
mod simple_logger; | ||
|
||
pub fn init(level: log::Level) { | ||
#[cfg(target_family = "wasm")] | ||
{ | ||
wasm_logger::init(wasm_logger::Config::new(level)); | ||
} | ||
|
||
#[cfg(not(target_family = "wasm"))] | ||
{ | ||
match set_boxed_logger(Box::new(simple_logger::SimpleLogger)) { | ||
Ok(_) => log::set_max_level(level.to_level_filter()), | ||
Err(e) => panic!("Failed to initialize logger: {}", e), | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
use log::{Record, Metadata}; | ||
|
||
pub struct SimpleLogger; | ||
|
||
impl log::Log for SimpleLogger { | ||
fn enabled(&self, metadata: &Metadata) -> bool { | ||
metadata.level() <= log::max_level() | ||
} | ||
|
||
fn log(&self, record: &Record) { | ||
if self.enabled(record.metadata()) { | ||
println!("{} - {}", record.level(), record.args()); | ||
} | ||
} | ||
|
||
fn flush(&self) {} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.