PluralKit/lib/libpk/src/lib.rs

35 lines
820 B
Rust
Raw Normal View History

2023-03-18 23:06:55 -04:00
use metrics_exporter_prometheus::PrometheusBuilder;
use tracing_subscriber::EnvFilter;
2023-02-15 19:27:36 -05:00
pub mod db;
pub mod proto;
2024-09-14 12:19:47 +09:00
pub mod util;
pub mod _config;
2023-02-15 19:27:36 -05:00
pub use crate::_config::CONFIG as config;
pub fn init_logging(component: &str) -> anyhow::Result<()> {
2024-09-14 12:19:47 +09:00
// todo: fix component
if config.json_log {
tracing_subscriber::fmt()
.json()
.with_env_filter(EnvFilter::from_default_env())
.init();
2023-02-15 19:27:36 -05:00
} else {
2024-09-14 12:19:47 +09:00
tracing_subscriber::fmt()
.with_env_filter(EnvFilter::from_default_env())
.init();
2023-02-15 19:27:36 -05:00
}
Ok(())
}
2023-03-18 23:06:55 -04:00
pub fn init_metrics() -> anyhow::Result<()> {
if config.run_metrics_server {
// automatically spawns a http listener at :9000
let builder = PrometheusBuilder::new();
builder.install()?;
}
Ok(())
}