feat: add proper logging
This commit is contained in:
2
swordfish-common/src/constants.rs
Normal file
2
swordfish-common/src/constants.rs
Normal file
@ -0,0 +1,2 @@
|
||||
pub const KATANA_ID: u64 = 646937666251915264;
|
||||
pub const SOFA_ID: u64 = 853629533855809596;
|
||||
@ -1,14 +1,33 @@
|
||||
pub fn add(left: usize, right: usize) -> usize {
|
||||
left + right
|
||||
}
|
||||
pub use log;
|
||||
pub use tracing::{debug, error, info, trace, warn};
|
||||
use tracing_subscriber::{self, fmt, EnvFilter};
|
||||
pub mod constants;
|
||||
pub mod tesseract;
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn it_works() {
|
||||
let result = add(2, 2);
|
||||
assert_eq!(result, 4);
|
||||
}
|
||||
pub fn setup_logger(level: &str) -> Result<(), fern::InitError> {
|
||||
// I don't really know how to do it because the unset variable trick doesn't work
|
||||
// since the types can be
|
||||
let formatter = fmt::format()
|
||||
.with_level(true)
|
||||
.with_target(true)
|
||||
.with_thread_ids(false)
|
||||
.with_thread_names(false); // include the name of the current thread.pretty();
|
||||
let filter = EnvFilter::builder()
|
||||
.from_env()
|
||||
.unwrap()
|
||||
.add_directive(
|
||||
format!("swordfish={}", level.to_lowercase())
|
||||
.parse()
|
||||
.unwrap(),
|
||||
)
|
||||
.add_directive(
|
||||
format!("swordfish-common={}", level.to_lowercase())
|
||||
.parse()
|
||||
.unwrap(),
|
||||
);
|
||||
tracing_subscriber::fmt()
|
||||
.event_format(formatter)
|
||||
.with_env_filter(filter)
|
||||
.init();
|
||||
Ok(())
|
||||
}
|
||||
|
||||
1
swordfish-common/src/tesseract.rs
Normal file
1
swordfish-common/src/tesseract.rs
Normal file
@ -0,0 +1 @@
|
||||
pub use leptess::LepTess;
|
||||
3
swordfish-common/src/utils/karuta.rs
Normal file
3
swordfish-common/src/utils/karuta.rs
Normal file
@ -0,0 +1,3 @@
|
||||
fn parse_card() {
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user