feat: add proper logging

This commit is contained in:
2023-12-30 21:39:44 +07:00
parent 1f7b5fe125
commit 19dc2963f5
13 changed files with 961 additions and 23 deletions

View File

@ -0,0 +1,2 @@
pub const KATANA_ID: u64 = 646937666251915264;
pub const SOFA_ID: u64 = 853629533855809596;

View File

@ -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(())
}

View File

@ -0,0 +1 @@
pub use leptess::LepTess;

View File

@ -0,0 +1,3 @@
fn parse_card() {
}