feat: add logging
This commit is contained in:
@@ -24,8 +24,9 @@ opt-level = 3
|
|||||||
debug = false
|
debug = false
|
||||||
|
|
||||||
[features]
|
[features]
|
||||||
default = ["pamsock"]
|
default = ["pamsock", "log"]
|
||||||
pamsock = ["dep:pamsock"]
|
pamsock = ["dep:pamsock"]
|
||||||
|
log = ["dep:log", "dep:env_logger"]
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
pamsock = { version = "0.2.0", git = "https://git.javalsai.tuxcord.net/tuxcord/authy-pamsock.git", features = [
|
pamsock = { version = "0.2.0", git = "https://git.javalsai.tuxcord.net/tuxcord/authy-pamsock.git", features = [
|
||||||
@@ -38,8 +39,10 @@ anyhow = "1.0"
|
|||||||
clap = { version = "4.5", features = ["derive"] }
|
clap = { version = "4.5", features = ["derive"] }
|
||||||
const-macros = { git = "https://git.javalsai.tuxcord.net/rust/const-macros.git", version = "0.1.2" }
|
const-macros = { git = "https://git.javalsai.tuxcord.net/rust/const-macros.git", version = "0.1.2" }
|
||||||
const-str = { version = "1.1", features = ["proc"] }
|
const-str = { version = "1.1", features = ["proc"] }
|
||||||
|
env_logger = { version = "0.11.10", optional = true }
|
||||||
futures-util = "0.3"
|
futures-util = "0.3"
|
||||||
libc = "0.2"
|
libc = "0.2"
|
||||||
|
log = { version = "0.4.29", optional = true }
|
||||||
magic = "0.16"
|
magic = "0.16"
|
||||||
moka = { version = "0.12", features = ["async-lock", "future"] }
|
moka = { version = "0.12", features = ["async-lock", "future"] }
|
||||||
serde = { version = "1.0", features = ["derive"] }
|
serde = { version = "1.0", features = ["derive"] }
|
||||||
|
|||||||
@@ -45,6 +45,8 @@ pub mod utils;
|
|||||||
#[tokio::main]
|
#[tokio::main]
|
||||||
async fn main() -> anyhow::Result<()> {
|
async fn main() -> anyhow::Result<()> {
|
||||||
let args = args::Args::parse();
|
let args = args::Args::parse();
|
||||||
|
#[cfg(feature = "log")]
|
||||||
|
env_logger::init_from_env(env_logger::Env::new().default_filter_or("info"));
|
||||||
let conf = if let Some(conf) = File::try_open(&args.conf) {
|
let conf = if let Some(conf) = File::try_open(&args.conf) {
|
||||||
conf::Config::from_toml_file(&mut conf?)?
|
conf::Config::from_toml_file(&mut conf?)?
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -38,6 +38,9 @@ pub async fn start_app(args: crate::args::Args, config: crate::conf::Config) ->
|
|||||||
HttpServer::new(move || {
|
HttpServer::new(move || {
|
||||||
App::new()
|
App::new()
|
||||||
.app_data(app)
|
.app_data(app)
|
||||||
|
.wrap(actix_web::middleware::Logger::new(
|
||||||
|
"%a (%{r}a) %r -> %s, %b B in %T s",
|
||||||
|
))
|
||||||
.service(services::images::make_scope(ws::IMAGES))
|
.service(services::images::make_scope(ws::IMAGES))
|
||||||
.default_service(web::to(services::not_found::not_found))
|
.default_service(web::to(services::not_found::not_found))
|
||||||
})
|
})
|
||||||
|
|||||||
Reference in New Issue
Block a user