fuzzysearch/fuzzysearch-common/src/lib.rs

34 lines
940 B
Rust
Raw Normal View History

#[cfg(feature = "queue")]
pub mod faktory;
2020-12-07 23:41:32 +00:00
pub mod types;
#[cfg(feature = "trace")]
pub mod trace;
2021-08-22 05:37:36 +00:00
#[cfg(feature = "download")]
pub mod download;
2020-12-07 23:41:32 +00:00
/// Create an instance of img_hash with project defaults.
pub fn get_hasher() -> img_hash::Hasher<[u8; 8]> {
use img_hash::{HashAlg::Gradient, HasherConfig};
HasherConfig::with_bytes_type::<[u8; 8]>()
.hash_alg(Gradient)
.hash_size(8, 8)
.preproc_dct()
.to_hasher()
}
2021-04-22 01:46:10 +00:00
/// Initialize the logger. This should only be called by the running binary.
pub fn init_logger() {
if matches!(std::env::var("LOG_FMT").as_deref(), Ok("json")) {
tracing_subscriber::fmt::Subscriber::builder()
.json()
.with_env_filter(tracing_subscriber::EnvFilter::from_default_env())
2021-12-09 04:45:17 +00:00
.with_timer(tracing_subscriber::fmt::time::UtcTime::rfc_3339())
2021-04-22 01:46:10 +00:00
.init();
} else {
tracing_subscriber::fmt::init();
}
}