-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #17 from perryrh0dan/dev
Dev
- Loading branch information
Showing
16 changed files
with
346 additions
and
397 deletions.
There are no files selected for viewing
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
Large diffs are not rendered by default.
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
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
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,38 @@ | ||
use log::LevelFilter; | ||
use log4rs::{ | ||
append::{ | ||
console::{ConsoleAppender, Target}, | ||
file::FileAppender, | ||
}, | ||
config::{Appender, Config, Root}, | ||
encode::pattern::PatternEncoder, | ||
filter::threshold::ThresholdFilter, | ||
}; | ||
|
||
use crate::config; | ||
|
||
pub fn init() { | ||
// Build a stderr logger. | ||
let stderr = ConsoleAppender::builder() | ||
.encoder(Box::new(PatternEncoder::new("{d(%Y-%m-%d %H:%M:%S)} {l} - {m}\n"))) | ||
.target(Target::Stderr) | ||
.build(); | ||
|
||
// Logging to log file | ||
let logfile_path = config::directory().join("log/output.log"); | ||
|
||
let logfile = FileAppender::builder() | ||
.encoder(Box::new(PatternEncoder::new("{d(%Y-%m-%d %H:%M:%S)} {l} - {m}\n"))) | ||
.build(logfile_path).unwrap(); | ||
|
||
|
||
let config = Config::builder() | ||
.appender(Appender::builder().build("logfile", Box::new(logfile))) | ||
.appender(Appender::builder().filter(Box::new(ThresholdFilter::new(log::LevelFilter::Error))).build("stderr", Box::new(stderr))) | ||
.build(Root::builder() | ||
.appender("logfile") | ||
.appender("stderr") | ||
.build(LevelFilter::Info)).unwrap(); | ||
|
||
log4rs::init_config(config).unwrap(); | ||
} |
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
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 |
---|---|---|
@@ -1,6 +0,0 @@ | ||
use colored::Colorize; | ||
|
||
pub fn no_subcommand() { | ||
let text = format!("No subcommand was used").yellow(); | ||
println!("{}", text); | ||
} | ||
Oops, something went wrong.