mirror of
https://github.com/sigoden/dufs.git
synced 2026-04-09 00:59:02 +03:00
refactor: use logger (#22)
This commit is contained in:
16
src/main.rs
16
src/main.rs
@@ -2,8 +2,14 @@ mod args;
|
||||
mod auth;
|
||||
mod server;
|
||||
|
||||
#[macro_use]
|
||||
extern crate log;
|
||||
|
||||
pub type BoxResult<T> = Result<T, Box<dyn std::error::Error>>;
|
||||
|
||||
use std::env;
|
||||
use std::io::Write;
|
||||
|
||||
use crate::args::{encode_uri, matches, Args};
|
||||
use crate::server::serve;
|
||||
|
||||
@@ -13,6 +19,16 @@ async fn main() {
|
||||
}
|
||||
|
||||
async fn run() -> BoxResult<()> {
|
||||
if env::var("RUST_LOG").is_err() {
|
||||
env::set_var("RUST_LOG", "info")
|
||||
}
|
||||
env_logger::builder()
|
||||
.format(|buf, record| {
|
||||
let timestamp = buf.timestamp();
|
||||
writeln!(buf, "[{} {}] {}", timestamp, record.level(), record.args())
|
||||
})
|
||||
.init();
|
||||
|
||||
let args = Args::parse(matches())?;
|
||||
tokio::select! {
|
||||
ret = serve(args) => {
|
||||
|
||||
Reference in New Issue
Block a user