Skip to content

Commit

Permalink
feat: aware RUST_LOG
Browse files Browse the repository at this point in the history
  • Loading branch information
sigoden committed May 28, 2022
1 parent d9a9171 commit 3673a64
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 12 deletions.
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "duf"
version = "0.2.0"
version = "0.2.1"
edition = "2021"
authors = ["sigoden <[email protected]>"]
description = "Duf is a simple file server."
Expand Down
2 changes: 0 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,6 @@ duf --static

Finally, run this command to see a list of all available option



### Curl

Download a file
Expand Down
18 changes: 11 additions & 7 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,18 @@ async fn main() {
async fn run() -> BoxResult<()> {
let args = Args::parse(matches())?;

let level = if args.log {
LevelFilter::Info
if std::env::var("RUST_LOG").is_ok() {
simple_logger::init()?;
} else {
LevelFilter::Error
};
simple_logger::SimpleLogger::default()
.with_level(level)
.init()?;
let level = if args.log {
LevelFilter::Info
} else {
LevelFilter::Error
};
simple_logger::SimpleLogger::default()
.with_level(level)
.init()?;
}
serve(args).await
}

Expand Down
2 changes: 1 addition & 1 deletion src/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ impl InnerService {
}

async fn handle_send_dir_zip(&self, path: &Path) -> BoxResult<Response> {
let (mut writer, reader) = tokio::io::duplex(65536);
let (mut writer, reader) = tokio::io::duplex(1024 * 1024 * 20);
dir_zip(&mut writer, path).await?;
let stream = ReaderStream::new(reader);
let body = Body::wrap_stream(stream);
Expand Down

0 comments on commit 3673a64

Please sign in to comment.