Added some basic code
Added basic settings representation and a way to load them from either a YAML or Json file.
This commit is contained in:
46
src/lib.rs
46
src/lib.rs
@@ -1,7 +1,45 @@
|
||||
use std::fs::File;
|
||||
use std::io::Result;
|
||||
use std::path::PathBuf;
|
||||
|
||||
extern crate log;
|
||||
extern crate simplelog;
|
||||
use log::{info, warn};
|
||||
use simplelog::*;
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
#[test]
|
||||
fn it_works() {
|
||||
assert_eq!(2 + 2, 4);
|
||||
mod tests;
|
||||
|
||||
mod settings;
|
||||
use settings::utils;
|
||||
|
||||
#[allow(dead_code)]
|
||||
pub fn init() -> std::result::Result<(), log::SetLoggerError> {
|
||||
match CombinedLogger::init(vec![
|
||||
TermLogger::new(
|
||||
LevelFilter::Warn,
|
||||
Config::default(),
|
||||
TerminalMode::Mixed,
|
||||
)
|
||||
.unwrap(),
|
||||
WriteLogger::new(
|
||||
LevelFilter::Info,
|
||||
Config::default(),
|
||||
File::create("core.log").unwrap(),
|
||||
),
|
||||
]) {
|
||||
Err(why) => {
|
||||
warn!("Could not initialize logger: {}", why.to_string());
|
||||
Err(why)
|
||||
}
|
||||
Ok(_) => {
|
||||
info!("Logger initialized");
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[allow(dead_code)]
|
||||
fn import_words(path: PathBuf) -> Result<String> {
|
||||
utils::read_file(&path)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user