Skip to content

Replace log and env_logger with tracing crates #3115

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Dec 28, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
136 changes: 115 additions & 21 deletions Cargo.lock

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

4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,6 @@ dialoguer = "0.7.1"
diesel = { version = "1.4.0", features = ["postgres", "serde_json", "chrono", "r2d2"] }
diesel_full_text_search = "1.0.0"
dotenv = "0.15"
env_logger = "0.8"
failure = "0.1.1"
flate2 = "1.0"
futures-channel = { version = "0.3.1", default-features = false }
Expand All @@ -69,7 +68,6 @@ indexmap = "1.0.2"
jemallocator = { version = "0.3", features = ['unprefixed_malloc_on_supported_platforms', 'profiling'] }
lettre = { version = "0.10.0-alpha.1", default-features = false, features = ["file-transport", "smtp-transport", "native-tls", "hostname", "builder"] }
license-exprs = "^1.4"
log = "0.4"
oauth2 = { version = "3.0.0", default-features = false, features = ["reqwest-010"] }
parking_lot = "0.11"
rand = "0.7"
Expand All @@ -85,6 +83,8 @@ tar = "0.4.16"
tempfile = "3"
tokio = { version = "0.2", default-features = false, features = ["net", "signal", "io-std"]}
toml = "0.5"
tracing = "0.1"
tracing-subscriber = "0.2"
url = "2.1"

[dev-dependencies]
Expand Down
2 changes: 1 addition & 1 deletion src/bin/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
});

// Initialize logging
env_logger::init();
tracing_subscriber::fmt::init();

let config = cargo_registry::Config::default();
let client = Client::new();
Expand Down
4 changes: 2 additions & 2 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@ extern crate derive_deref;
#[macro_use]
extern crate diesel;
#[macro_use]
extern crate log;
#[macro_use]
extern crate serde;
#[macro_use]
extern crate serde_json;
#[macro_use]
extern crate tracing;

pub use crate::{app::App, config::Config, uploaders::Uploader};
use std::sync::Arc;
Expand Down
4 changes: 2 additions & 2 deletions src/tests/all.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@ extern crate diesel;
#[macro_use]
extern crate lazy_static;
#[macro_use]
extern crate log;
#[macro_use]
extern crate serde;
#[macro_use]
extern crate serde_json;
#[macro_use]
extern crate tracing;

use crate::util::{RequestHelper, TestApp};
use cargo_registry::{
Expand Down
7 changes: 4 additions & 3 deletions src/tests/util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,10 @@ use url::Url;
pub use conduit::{header, StatusCode};

pub fn init_logger() {
let _ = env_logger::builder()
.format_timestamp(None)
.is_test(true)
let _ = tracing_subscriber::fmt()
.with_env_filter(tracing_subscriber::EnvFilter::from_default_env())
.without_time()
.with_test_writer()
.try_init();
}

Expand Down