Skip to content

Commit

Permalink
enabled optional logging
Browse files Browse the repository at this point in the history
* added description about the env variables to README.md
[ci-build]
  • Loading branch information
prixt committed Feb 21, 2020
1 parent 8204d7e commit c3fcbcd
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 14 deletions.
20 changes: 10 additions & 10 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,11 @@ This pattern will make soundsense-rs ignore any cancallations related to water.

The regex pattern uses the [regex crate](https://docs.rs/regex/) syntax.

## Logging
You can set the following environment variables to set the logging parameters. (Disabled on Windows releases)
* __SOUNDSENSE_RS_LOG__: set the level of logging. _(trace, debug, info, warn, error; default: warn)_
* __SOUNDSENSE_RS_LOG_STYLE__: st the level of the log style. _(always, never; default: always)_

## Dependencies
Linux: libasound2, libgtk-3, libwebkit2gtk-4.0

Expand Down
8 changes: 5 additions & 3 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,17 @@ use std::env;
use std::sync::mpsc::channel;
use std::path::PathBuf;
use regex::Regex;
#[macro_use]
extern crate log;
#[macro_use] extern crate log;

mod sound;
mod ui;
mod message;

fn main() {
env_logger::init();
let env = env_logger::Env::default()
.filter_or("SOUNDSENSE_RS_LOG", "warn")
.write_style_or("SOUNDSENSE_RS_LOG_STYLE", "always");
env_logger::init_from_env(env);
info!("Starting SoundSense-RS");
let args: Vec<String> = env::args().collect();
let mut opts = getopts::Options::new();
Expand Down
1 change: 0 additions & 1 deletion src/sound.rs
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,6 @@ pub struct SoundEntry {
}

pub fn run(sound_rx: Receiver<SoundMessage>, ui_tx: Sender<UIMessage>) {

loop {
info!("(Re)Starting sound thread.");
let mut manager : Option<SoundManager> = None;
Expand Down

0 comments on commit c3fcbcd

Please sign in to comment.