Skip to content

Commit

Permalink
all: Calling env_logger::init() will fail if a logger already was ini…
Browse files Browse the repository at this point in the history
…tialized. This likely happens when tests are ran. We now try to initialize it but don't panic if it was already initialized.
  • Loading branch information
pentamassiv committed Nov 21, 2024
1 parent 4fd9b8e commit 1353fce
Show file tree
Hide file tree
Showing 8 changed files with 8 additions and 8 deletions.
2 changes: 1 addition & 1 deletion examples/key.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use std::thread;
use std::time::Duration;

fn main() {
env_logger::init();
env_logger::try_init().ok();
thread::sleep(Duration::from_secs(2));
let mut enigo = Enigo::new(&Settings::default()).unwrap();

Expand Down
2 changes: 1 addition & 1 deletion examples/keyboard.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use std::thread;
use std::time::Duration;

fn main() {
env_logger::init();
env_logger::try_init().ok();
thread::sleep(Duration::from_secs(2));
let mut enigo = Enigo::new(&Settings::default()).unwrap();

Expand Down
2 changes: 1 addition & 1 deletion examples/layout.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use std::thread;
use std::time::Duration;

fn main() {
env_logger::init();
env_logger::try_init().ok();
thread::sleep(Duration::from_secs(4));
let mut enigo = Enigo::new(&Settings::default()).unwrap();

Expand Down
2 changes: 1 addition & 1 deletion examples/mouse.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use std::thread;
use std::time::Duration;

fn main() {
env_logger::init();
env_logger::try_init().ok();
let wait_time = Duration::from_secs(2);
let mut enigo = Enigo::new(&Settings::default()).unwrap();

Expand Down
2 changes: 1 addition & 1 deletion examples/platform_specific.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use std::time::Duration;

// This example will do different things depending on the platform
fn main() {
env_logger::init();
env_logger::try_init().ok();
thread::sleep(Duration::from_secs(2));
let mut enigo = Enigo::new(&Settings::default()).unwrap();

Expand Down
2 changes: 1 addition & 1 deletion examples/serde.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use enigo::{
use std::{thread, time::Duration};

fn main() {
env_logger::init();
env_logger::try_init().ok();
thread::sleep(Duration::from_secs(2));
let mut enigo = Enigo::new(&Settings::default()).unwrap();

Expand Down
2 changes: 1 addition & 1 deletion examples/timer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ use std::{
};

fn main() {
env_logger::init();
env_logger::try_init().ok();
thread::sleep(Duration::from_secs(2));
let mut enigo = Enigo::new(&Settings::default()).unwrap();

Expand Down
2 changes: 1 addition & 1 deletion tests/common/enigo_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ pub struct EnigoTest {

impl EnigoTest {
pub fn new(settings: &Settings) -> Self {
env_logger::init();
env_logger::try_init().ok();
EnigoTest::start_timeout_thread();
let enigo = Enigo::new(settings).unwrap();
let _ = &*super::browser::BROWSER_INSTANCE; // Launch Firefox
Expand Down

0 comments on commit 1353fce

Please sign in to comment.