Skip to content

Commit

Permalink
feat: Enable logging for opendal operations
Browse files Browse the repository at this point in the history
Signed-off-by: Xuanwo <github@xuanwo.io>
  • Loading branch information
Xuanwo authored and sylvestre committed Dec 23, 2022
1 parent 2c13a72 commit 7779f71
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 5 deletions.
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

0 comments on commit 7779f71

Please sign in to comment.