Skip to content
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

chore: change log subscriber from env_logger to tracing-subscriber #2238

Merged
merged 2 commits into from
May 8, 2023
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
1 change: 0 additions & 1 deletion Cargo.lock

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

1 change: 0 additions & 1 deletion core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,6 @@ uuid = { version = "1", features = ["serde", "v4"] }
[dev-dependencies]
criterion = { version = "0.4", features = ["async", "async_tokio"] }
dotenvy = "0.15"
env_logger = "0.10"
opentelemetry = { version = "0.19", default-features = false, features = [
"trace",
] }
Expand Down
4 changes: 2 additions & 2 deletions core/examples/object.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ use opendal::Result;
/// Visit [`opendal::Object`] for more object level APIs.
#[tokio::main]
async fn main() -> Result<()> {
let _ = env_logger::builder()
.filter_level(log::LevelFilter::Debug)
let _ = tracing_subscriber::fmt()
.with_env_filter("debug")
.try_init();

// Pick a builder and configure it.
Expand Down
8 changes: 4 additions & 4 deletions core/src/layers/immutable_index.rs
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,7 @@ mod tests {

#[tokio::test]
async fn test_list() -> Result<()> {
let _ = env_logger::try_init();
let _ = tracing_subscriber::fmt().with_test_writer().try_init();

let mut iil = ImmutableIndexLayer::default();
for i in ["file", "dir/", "dir/file", "dir_without_prefix/file"] {
Expand Down Expand Up @@ -322,7 +322,7 @@ mod tests {

#[tokio::test]
async fn test_scan() -> Result<()> {
let _ = env_logger::try_init();
let _ = tracing_subscriber::fmt().with_test_writer().try_init();

let mut iil = ImmutableIndexLayer::default();
for i in ["file", "dir/", "dir/file", "dir_without_prefix/file"] {
Expand Down Expand Up @@ -362,7 +362,7 @@ mod tests {

#[tokio::test]
async fn test_list_dir() -> Result<()> {
let _ = env_logger::try_init();
let _ = tracing_subscriber::fmt().with_test_writer().try_init();

let mut iil = ImmutableIndexLayer::default();
for i in [
Expand Down Expand Up @@ -423,7 +423,7 @@ mod tests {

#[tokio::test]
async fn test_walk_top_down_dir() -> Result<()> {
let _ = env_logger::try_init();
let _ = tracing_subscriber::fmt().with_test_writer().try_init();

let mut iil = ImmutableIndexLayer::default();
for i in [
Expand Down
6 changes: 3 additions & 3 deletions core/src/layers/retry.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1012,7 +1012,7 @@ mod tests {

#[tokio::test]
async fn test_retry_read() {
let _ = env_logger::try_init();
let _ = tracing_subscriber::fmt().with_test_writer().try_init();

let builder = MockBuilder::default();
let op = Operator::new(builder.clone())
Expand All @@ -1034,7 +1034,7 @@ mod tests {

#[tokio::test]
async fn test_retry_list() {
let _ = env_logger::try_init();
let _ = tracing_subscriber::fmt().with_test_writer().try_init();

let builder = MockBuilder::default();
let op = Operator::new(builder.clone())
Expand All @@ -1058,7 +1058,7 @@ mod tests {

#[tokio::test]
async fn test_retry_batch() {
let _ = env_logger::try_init();
let _ = tracing_subscriber::fmt().with_test_writer().try_init();

let builder = MockBuilder::default();
// set to a lower delay to make it run faster
Expand Down
2 changes: 1 addition & 1 deletion core/src/raw/oio/to_flat_pager.rs
Original file line number Diff line number Diff line change
Expand Up @@ -299,7 +299,7 @@ mod tests {

#[test]
fn test_blocking_list() -> Result<()> {
let _ = env_logger::try_init();
let _ = tracing_subscriber::fmt().with_test_writer().try_init();

let acc = MockService::new();
let mut pager = to_flat_pager(acc, "x/", 10);
Expand Down
2 changes: 1 addition & 1 deletion core/src/raw/oio/to_hierarchy_pager.rs
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ mod tests {

#[test]
fn test_blocking_list() -> Result<()> {
let _ = env_logger::try_init();
let _ = tracing_subscriber::fmt().with_test_writer().try_init();

let pager = MockPager::new(&["x/x/", "x/y/", "y/", "x/x/x", "y/y", "xy/", "z", "y/a"]);
let mut pager = to_hierarchy_pager(pager, "");
Expand Down
12 changes: 6 additions & 6 deletions core/src/services/http/backend.rs
Original file line number Diff line number Diff line change
Expand Up @@ -406,7 +406,7 @@ mod tests {

#[tokio::test]
async fn test_read() -> Result<()> {
let _ = env_logger::builder().is_test(true).try_init();
let _ = tracing_subscriber::fmt().with_test_writer().try_init();

let mock_server = MockServer::start().await;
Mock::given(method("GET"))
Expand All @@ -432,7 +432,7 @@ mod tests {

#[tokio::test]
async fn test_read_via_basic_auth() -> Result<()> {
let _ = env_logger::builder().is_test(true).try_init();
let _ = tracing_subscriber::fmt().with_test_writer().try_init();

let (username, password) = ("your_username", "your_password");

Expand Down Expand Up @@ -462,7 +462,7 @@ mod tests {

#[tokio::test]
async fn test_read_via_bearer_auth() -> Result<()> {
let _ = env_logger::builder().is_test(true).try_init();
let _ = tracing_subscriber::fmt().with_test_writer().try_init();

let token = "your_token";

Expand Down Expand Up @@ -492,7 +492,7 @@ mod tests {

#[tokio::test]
async fn test_stat() -> Result<()> {
let _ = env_logger::builder().is_test(true).try_init();
let _ = tracing_subscriber::fmt().with_test_writer().try_init();

let mock_server = MockServer::start().await;
Mock::given(method("HEAD"))
Expand All @@ -514,7 +514,7 @@ mod tests {

#[tokio::test]
async fn test_read_with() -> Result<()> {
let _ = env_logger::builder().is_test(true).try_init();
let _ = tracing_subscriber::fmt().with_test_writer().try_init();

let mock_server = MockServer::start().await;
Mock::given(method("GET"))
Expand Down Expand Up @@ -543,7 +543,7 @@ mod tests {

#[tokio::test]
async fn test_stat_with() -> Result<()> {
let _ = env_logger::builder().is_test(true).try_init();
let _ = tracing_subscriber::fmt().with_test_writer().try_init();

let mock_server = MockServer::start().await;
Mock::given(method("HEAD"))
Expand Down
2 changes: 1 addition & 1 deletion core/src/services/s3/backend.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1223,7 +1223,7 @@ mod tests {

#[test]
fn test_build_endpoint() {
let _ = env_logger::try_init();
let _ = tracing_subscriber::fmt().with_test_writer().try_init();

let endpoint_cases = vec![
Some("s3.amazonaws.com"),
Expand Down
2 changes: 1 addition & 1 deletion core/tests/behavior/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ use sha2::Sha256;
/// - If `opendal_{schema}_test` is on, construct a new Operator with given root.
/// - Else, returns a `None` to represent no valid config for operator.
pub fn init_service<B: Builder>() -> Option<Operator> {
let _ = env_logger::builder().is_test(true).try_init();
let _ = tracing_subscriber::fmt().with_test_writer().try_init();
let _ = dotenvy::dotenv();

let prefix = format!("opendal_{}_", B::SCHEME);
Expand Down