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

feat: Enable logging for opendal operations #1497

Merged
merged 1 commit into from
Dec 23, 2022
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
4 changes: 3 additions & 1 deletion src/cache/azure.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@

use opendal::Operator;

use opendal::layers::LoggingLayer;
use opendal::services::azblob;

use crate::errors::*;
Expand All @@ -27,6 +28,7 @@ impl AzureBlobCache {
builder.container(container);
builder.root(key_prefix);

Ok(builder.build()?.into())
let op: Operator = builder.build()?.into();
Ok(op.layer(LoggingLayer::default()))
}
}
3 changes: 2 additions & 1 deletion src/cache/cache.rs
Original file line number Diff line number Diff line change
Expand Up @@ -335,8 +335,9 @@ impl Storage for opendal::Operator {
let hit = CacheRead::from(io::Cursor::new(res))?;
Ok(Cache::Hit(hit))
}
Err(e) if e.kind() == opendal::ErrorKind::ObjectNotFound => Ok(Cache::Miss),
Err(e) => {
warn!("Got error: {:?}", e);
warn!("Got unexpected error: {:?}", e);
Ok(Cache::Miss)
}
}
Expand Down
5 changes: 3 additions & 2 deletions src/cache/gcs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@
// limitations under the License.

use crate::errors::*;
use opendal::services::gcs;
use opendal::Operator;
use opendal::{layers::LoggingLayer, services::gcs};
use reqsign::{GoogleBuilder, GoogleToken, GoogleTokenLoad};

#[derive(Copy, Clone)]
Expand Down Expand Up @@ -67,7 +67,8 @@ impl GCSCache {
}
builder.signer(signer_builder.build()?);

Ok(builder.build()?.into())
let op: Operator = builder.build()?.into();
Ok(op.layer(LoggingLayer::default()))
}
}

Expand Down
4 changes: 3 additions & 1 deletion src/cache/s3.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.

use opendal::layers::LoggingLayer;
use opendal::services::s3;
use opendal::Operator;

Expand Down Expand Up @@ -41,7 +42,8 @@ impl S3Cache {
builder.endpoint(&endpoint_resolver(endpoint, use_ssl)?);
}

Ok(builder.build()?.into())
let op: Operator = builder.build()?.into();
Ok(op.layer(LoggingLayer::default()))
}
}

Expand Down