Re: [PR] [#5873] feat(gvfs-fuse): add debug log for FuseApiHandle [gravitino]

2025-03-20 Thread via GitHub


unknowntpo commented on PR #5905:
URL: https://github.com/apache/gravitino/pull/5905#issuecomment-2740534767

   > LGTM
   @diqiu50 
   Thank you for reviewing my PR, I learned a lot from it !


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]



Re: [PR] [#5873] feat(gvfs-fuse): add debug log for FuseApiHandle [gravitino]

2025-03-20 Thread via GitHub


diqiu50 merged PR #5905:
URL: https://github.com/apache/gravitino/pull/5905


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]



Re: [PR] [#5873] feat(gvfs-fuse): add debug log for FuseApiHandle [gravitino]

2025-03-17 Thread via GitHub


unknowntpo commented on PR #5905:
URL: https://github.com/apache/gravitino/pull/5905#issuecomment-2731413239

   > You need to update the description for the PR and provide the best usage 
examples and log output.
   
   @diqiu50 I've updated the description, please take a look.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]



Re: [PR] [#5873] feat(gvfs-fuse): add debug log for FuseApiHandle [gravitino]

2025-03-16 Thread via GitHub


unknowntpo commented on code in PR #5905:
URL: https://github.com/apache/gravitino/pull/5905#discussion_r1997838305


##
clients/filesystem-fuse/src/fuse_api_handle_debug.rs:
##
@@ -0,0 +1,829 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+use crate::config::AppConfig;
+use crate::filesystem::{FileSystemContext, RawFileSystem};
+use crate::fuse_api_handle::FuseApiHandle;
+use chrono::DateTime;
+use fuse3::path::prelude::{ReplyData, ReplyOpen, ReplyStatFs, ReplyWrite};
+use fuse3::path::Request;
+use fuse3::raw::prelude::{
+FileAttr, ReplyAttr, ReplyCreated, ReplyDirectory, ReplyDirectoryPlus, 
ReplyEntry, ReplyInit,
+};
+use fuse3::raw::reply::{DirectoryEntry, DirectoryEntryPlus};
+use fuse3::raw::Filesystem;
+use fuse3::{Inode, SetAttr, Timestamp};
+use futures_util::stream::{self, BoxStream};
+use futures_util::StreamExt;
+use std::ffi::OsStr;
+use std::fmt::Write;
+use tracing::{debug, error};
+
+/// Log the result without printing the reply
+macro_rules! log_status {
+($method_call:expr, $method_name:expr, $req:ident) => {
+match $method_call.await {
+Ok(reply) => {
+debug!($req.unique, "{} completed", 
$method_name.to_uppercase());
+Ok(reply)
+}
+Err(e) => {
+error!($req.unique, ?e, "{} failed", 
$method_name.to_uppercase());
+Err(e)
+}
+}
+};
+}
+
+/// Log the result with default Debug formatting
+macro_rules! log_value {
+($method_call:expr, $method_name:expr, $req:ident) => {
+match $method_call.await {
+Ok(reply) => {
+debug!(
+$req.unique,
+?reply,
+"{} completed",
+$method_name.to_uppercase()
+);
+Ok(reply)
+}
+Err(e) => {
+error!($req.unique, ?e, "{} failed", 
$method_name.to_uppercase());
+Err(e)
+}
+}
+};
+}
+
+/// Log the result with custom formatting
+macro_rules! log_value_custom {
+($method_call:expr, $method_name:expr, $req:ident, $format_reply_fn:ident) 
=> {
+match $method_call.await {
+Ok(reply) => {
+debug!(
+$req.unique,
+reply = $format_reply_fn(&reply),
+"{} completed",
+$method_name.to_uppercase()
+);
+Ok(reply)
+}
+Err(e) => {
+error!($req.unique, ?e, "{} failed", 
$method_name.to_uppercase());
+Err(e)
+}
+}
+};
+}
+
+/// Log the result for readdir operations
+macro_rules! log_readdir {
+($method_call:expr, $req:ident) => {{
+match $method_call.await {
+Ok(mut reply_dir) => {
+let mut entries = Vec::new();
+
+while let Some(entry_result) = reply_dir.entries.next().await {
+match entry_result {
+Ok(entry) => {
+entries.push(entry);
+}
+Err(e) => {
+return Err(e.into());
+}
+}
+}
+
+let entries_info = format!(
+"[{}]",
+entries
+.iter()
+.map(|entry| directory_entry_to_desc_str(entry))
+.collect::>()
+.join(", ")
+);
+
+debug!($req.unique, entries = entries_info, "READDIR 
completed");
+
+Ok(ReplyDirectory {
+entries: stream::iter(entries.into_iter().map(Ok)).boxed(),
+})
+}
+Err(e) => {
+error!($req.unique, ?e, "READDIR failed");
+Err(e)
+}
+}
+}};
+}
+
+/// Log the result for readdirplus operations
+macro_rules! log_readdirplus {
+($method_call:expr, $req:ident) => {{
+match $method_call.await {
+Ok(mut reply_

Re: [PR] [#5873] feat(gvfs-fuse): add debug log for FuseApiHandle [gravitino]

2025-03-16 Thread via GitHub


unknowntpo commented on code in PR #5905:
URL: https://github.com/apache/gravitino/pull/5905#discussion_r1997840855


##
clients/filesystem-fuse/src/main.rs:
##
@@ -193,6 +213,33 @@ fn main() -> Result<(), i32> {
 path.to_string_lossy().to_string()
 };
 
+if env::var("RUST_LOG").is_ok() {
+init_tracing_subscriber(LevelFilter::INFO, "");
+} else {
+// if debug > 0, it means that we needs fuse_debug.
+app_config.fuse.fuse_debug = debug > 0 || 
app_config.fuse.fuse_debug;
+match debug {
+0 => {
+init_tracing_subscriber(LevelFilter::INFO, "");

Review Comment:
   Ok, done, note that I also use `tracing_subscriber::reload` to reload the 
filter.
   Because previously in this PR, loggings like `error!`, `info!` will not be 
shown before calling `init_tracing_subscriber`.
   
   e8ad890efeae7a710f8ad39cbd09567c9dd30568



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]



Re: [PR] [#5873] feat(gvfs-fuse): add debug log for FuseApiHandle [gravitino]

2025-03-16 Thread via GitHub


unknowntpo commented on code in PR #5905:
URL: https://github.com/apache/gravitino/pull/5905#discussion_r1997839206


##
clients/filesystem-fuse/src/fuse_api_handle_debug.rs:
##
@@ -0,0 +1,829 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+use crate::config::AppConfig;
+use crate::filesystem::{FileSystemContext, RawFileSystem};
+use crate::fuse_api_handle::FuseApiHandle;
+use chrono::DateTime;
+use fuse3::path::prelude::{ReplyData, ReplyOpen, ReplyStatFs, ReplyWrite};
+use fuse3::path::Request;
+use fuse3::raw::prelude::{
+FileAttr, ReplyAttr, ReplyCreated, ReplyDirectory, ReplyDirectoryPlus, 
ReplyEntry, ReplyInit,
+};
+use fuse3::raw::reply::{DirectoryEntry, DirectoryEntryPlus};
+use fuse3::raw::Filesystem;
+use fuse3::{Inode, SetAttr, Timestamp};
+use futures_util::stream::{self, BoxStream};
+use futures_util::StreamExt;
+use std::ffi::OsStr;
+use std::fmt::Write;
+use tracing::{debug, error};
+
+/// Log the result without printing the reply
+macro_rules! log_status {
+($method_call:expr, $method_name:expr, $req:ident) => {
+match $method_call.await {
+Ok(reply) => {
+debug!($req.unique, "{} completed", 
$method_name.to_uppercase());
+Ok(reply)
+}
+Err(e) => {
+error!($req.unique, ?e, "{} failed", 
$method_name.to_uppercase());
+Err(e)
+}
+}
+};
+}
+
+/// Log the result with default Debug formatting
+macro_rules! log_value {
+($method_call:expr, $method_name:expr, $req:ident) => {
+match $method_call.await {
+Ok(reply) => {
+debug!(
+$req.unique,
+?reply,
+"{} completed",
+$method_name.to_uppercase()
+);
+Ok(reply)
+}
+Err(e) => {
+error!($req.unique, ?e, "{} failed", 
$method_name.to_uppercase());
+Err(e)
+}
+}
+};
+}
+
+/// Log the result with custom formatting
+macro_rules! log_value_custom {
+($method_call:expr, $method_name:expr, $req:ident, $format_reply_fn:ident) 
=> {
+match $method_call.await {
+Ok(reply) => {
+debug!(
+$req.unique,
+reply = $format_reply_fn(&reply),
+"{} completed",
+$method_name.to_uppercase()
+);
+Ok(reply)
+}
+Err(e) => {
+error!($req.unique, ?e, "{} failed", 
$method_name.to_uppercase());
+Err(e)
+}
+}
+};
+}
+
+/// Log the result for readdir operations
+macro_rules! log_readdir {
+($method_call:expr, $req:ident) => {{
+match $method_call.await {
+Ok(mut reply_dir) => {
+let mut entries = Vec::new();
+
+while let Some(entry_result) = reply_dir.entries.next().await {
+match entry_result {
+Ok(entry) => {
+entries.push(entry);
+}
+Err(e) => {
+return Err(e.into());
+}
+}
+}
+
+let entries_info = format!(
+"[{}]",
+entries
+.iter()
+.map(|entry| directory_entry_to_desc_str(entry))
+.collect::>()
+.join(", ")
+);
+
+debug!($req.unique, entries = entries_info, "READDIR 
completed");
+
+Ok(ReplyDirectory {
+entries: stream::iter(entries.into_iter().map(Ok)).boxed(),
+})
+}
+Err(e) => {
+error!($req.unique, ?e, "READDIR failed");
+Err(e)
+}
+}
+}};
+}
+
+/// Log the result for readdirplus operations
+macro_rules! log_readdirplus {
+($method_call:expr, $req:ident) => {{
+match $method_call.await {
+Ok(mut reply_

Re: [PR] [#5873] feat(gvfs-fuse): add debug log for FuseApiHandle [gravitino]

2025-03-15 Thread via GitHub


diqiu50 commented on code in PR #5905:
URL: https://github.com/apache/gravitino/pull/5905#discussion_r1990983471


##
clients/filesystem-fuse/src/main.rs:
##
@@ -193,6 +213,33 @@ fn main() -> Result<(), i32> {
 path.to_string_lossy().to_string()
 };
 
+if env::var("RUST_LOG").is_ok() {
+init_tracing_subscriber(LevelFilter::INFO, "");
+} else {
+// if debug > 0, it means that we needs fuse_debug.
+app_config.fuse.fuse_debug = debug > 0 || 
app_config.fuse.fuse_debug;
+match debug {
+0 => {
+init_tracing_subscriber(LevelFilter::INFO, "");

Review Comment:
   My point is that if the user sets RUST_LOG='info' and debug=1, the log level 
is equivalent to RUST_LOG="info, gvfs_fuse=debug".
   
   If RUST_LOG="info, open_dal=debug, s3=debug" and debug=1, the actual effect 
should be RUST_LOG="info, open_dal=debug, s3=debug, gvfs_fuse=debug".
   
   If RUST_LOG="gvfs_fuse=debug" and debug=1, the actual effect should be 
RUST_LOG="gvfs_fuse=debug".
   
   If RUST_LOG="gvfs_fuse=trace" and debug=1, the actual effect should be 
RUST_LOG="gvfs_fuse=trace".
   
   Of course, debug=1 requires enabling FuseApiHandleDebug.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]



Re: [PR] [#5873] feat(gvfs-fuse): add debug log for FuseApiHandle [gravitino]

2025-03-15 Thread via GitHub


unknowntpo commented on code in PR #5905:
URL: https://github.com/apache/gravitino/pull/5905#discussion_r1984374159


##
clients/filesystem-fuse/src/fuse_api_handle_debug.rs:
##
@@ -0,0 +1,829 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+use crate::config::AppConfig;
+use crate::filesystem::{FileSystemContext, RawFileSystem};
+use crate::fuse_api_handle::FuseApiHandle;
+use chrono::DateTime;
+use fuse3::path::prelude::{ReplyData, ReplyOpen, ReplyStatFs, ReplyWrite};
+use fuse3::path::Request;
+use fuse3::raw::prelude::{
+FileAttr, ReplyAttr, ReplyCreated, ReplyDirectory, ReplyDirectoryPlus, 
ReplyEntry, ReplyInit,
+};
+use fuse3::raw::reply::{DirectoryEntry, DirectoryEntryPlus};
+use fuse3::raw::Filesystem;
+use fuse3::{Inode, SetAttr, Timestamp};
+use futures_util::stream::{self, BoxStream};
+use futures_util::StreamExt;
+use std::ffi::OsStr;
+use std::fmt::Write;
+use tracing::{debug, error};
+
+/// Log the result without printing the reply
+macro_rules! log_status {
+($method_call:expr, $method_name:expr, $req:ident) => {
+match $method_call.await {
+Ok(reply) => {
+debug!($req.unique, "{} completed", 
$method_name.to_uppercase());
+Ok(reply)
+}
+Err(e) => {
+error!($req.unique, ?e, "{} failed", 
$method_name.to_uppercase());
+Err(e)
+}
+}
+};
+}
+
+/// Log the result with default Debug formatting
+macro_rules! log_value {
+($method_call:expr, $method_name:expr, $req:ident) => {
+match $method_call.await {
+Ok(reply) => {
+debug!(
+$req.unique,
+?reply,
+"{} completed",
+$method_name.to_uppercase()
+);
+Ok(reply)
+}
+Err(e) => {
+error!($req.unique, ?e, "{} failed", 
$method_name.to_uppercase());
+Err(e)
+}
+}
+};
+}
+
+/// Log the result with custom formatting
+macro_rules! log_value_custom {
+($method_call:expr, $method_name:expr, $req:ident, $format_reply_fn:ident) 
=> {
+match $method_call.await {
+Ok(reply) => {
+debug!(
+$req.unique,
+reply = $format_reply_fn(&reply),
+"{} completed",
+$method_name.to_uppercase()
+);
+Ok(reply)
+}
+Err(e) => {
+error!($req.unique, ?e, "{} failed", 
$method_name.to_uppercase());
+Err(e)
+}
+}
+};
+}
+
+/// Log the result for readdir operations
+macro_rules! log_readdir {
+($method_call:expr, $req:ident) => {{
+match $method_call.await {
+Ok(mut reply_dir) => {
+let mut entries = Vec::new();
+
+while let Some(entry_result) = reply_dir.entries.next().await {
+match entry_result {
+Ok(entry) => {
+entries.push(entry);
+}
+Err(e) => {
+return Err(e.into());
+}
+}
+}
+
+let entries_info = format!(
+"[{}]",
+entries
+.iter()
+.map(|entry| directory_entry_to_desc_str(entry))
+.collect::>()
+.join(", ")
+);
+
+debug!($req.unique, entries = entries_info, "READDIR 
completed");
+
+Ok(ReplyDirectory {
+entries: stream::iter(entries.into_iter().map(Ok)).boxed(),
+})
+}
+Err(e) => {
+error!($req.unique, ?e, "READDIR failed");
+Err(e)
+}
+}
+}};
+}
+
+/// Log the result for readdirplus operations
+macro_rules! log_readdirplus {
+($method_call:expr, $req:ident) => {{
+match $method_call.await {
+Ok(mut reply_

Re: [PR] [#5873] feat(gvfs-fuse): add debug log for FuseApiHandle [gravitino]

2025-03-15 Thread via GitHub


diqiu50 commented on code in PR #5905:
URL: https://github.com/apache/gravitino/pull/5905#discussion_r1986545413


##
clients/filesystem-fuse/src/fuse_api_handle_debug.rs:
##
@@ -0,0 +1,829 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+use crate::config::AppConfig;
+use crate::filesystem::{FileSystemContext, RawFileSystem};
+use crate::fuse_api_handle::FuseApiHandle;
+use chrono::DateTime;
+use fuse3::path::prelude::{ReplyData, ReplyOpen, ReplyStatFs, ReplyWrite};
+use fuse3::path::Request;
+use fuse3::raw::prelude::{
+FileAttr, ReplyAttr, ReplyCreated, ReplyDirectory, ReplyDirectoryPlus, 
ReplyEntry, ReplyInit,
+};
+use fuse3::raw::reply::{DirectoryEntry, DirectoryEntryPlus};
+use fuse3::raw::Filesystem;
+use fuse3::{Inode, SetAttr, Timestamp};
+use futures_util::stream::{self, BoxStream};
+use futures_util::StreamExt;
+use std::ffi::OsStr;
+use std::fmt::Write;
+use tracing::{debug, error};
+
+/// Log the result without printing the reply
+macro_rules! log_status {
+($method_call:expr, $method_name:expr, $req:ident) => {
+match $method_call.await {
+Ok(reply) => {
+debug!($req.unique, "{} completed", 
$method_name.to_uppercase());
+Ok(reply)
+}
+Err(e) => {
+error!($req.unique, ?e, "{} failed", 
$method_name.to_uppercase());
+Err(e)
+}
+}
+};
+}
+
+/// Log the result with default Debug formatting
+macro_rules! log_value {
+($method_call:expr, $method_name:expr, $req:ident) => {
+match $method_call.await {
+Ok(reply) => {
+debug!(
+$req.unique,
+?reply,
+"{} completed",
+$method_name.to_uppercase()
+);
+Ok(reply)
+}
+Err(e) => {
+error!($req.unique, ?e, "{} failed", 
$method_name.to_uppercase());
+Err(e)
+}
+}
+};
+}
+
+/// Log the result with custom formatting
+macro_rules! log_value_custom {
+($method_call:expr, $method_name:expr, $req:ident, $format_reply_fn:ident) 
=> {
+match $method_call.await {
+Ok(reply) => {
+debug!(
+$req.unique,
+reply = $format_reply_fn(&reply),
+"{} completed",
+$method_name.to_uppercase()
+);
+Ok(reply)
+}
+Err(e) => {
+error!($req.unique, ?e, "{} failed", 
$method_name.to_uppercase());
+Err(e)
+}
+}
+};
+}
+
+/// Log the result for readdir operations
+macro_rules! log_readdir {
+($method_call:expr, $req:ident) => {{
+match $method_call.await {
+Ok(mut reply_dir) => {
+let mut entries = Vec::new();
+
+while let Some(entry_result) = reply_dir.entries.next().await {
+match entry_result {
+Ok(entry) => {
+entries.push(entry);
+}
+Err(e) => {
+return Err(e.into());
+}
+}
+}
+
+let entries_info = format!(
+"[{}]",
+entries
+.iter()
+.map(|entry| directory_entry_to_desc_str(entry))
+.collect::>()
+.join(", ")
+);
+
+debug!($req.unique, entries = entries_info, "READDIR 
completed");
+
+Ok(ReplyDirectory {
+entries: stream::iter(entries.into_iter().map(Ok)).boxed(),
+})
+}
+Err(e) => {
+error!($req.unique, ?e, "READDIR failed");
+Err(e)
+}
+}
+}};
+}
+
+/// Log the result for readdirplus operations
+macro_rules! log_readdirplus {
+($method_call:expr, $req:ident) => {{
+match $method_call.await {
+Ok(mut reply_dir

Re: [PR] [#5873] feat(gvfs-fuse): add debug log for FuseApiHandle [gravitino]

2025-03-15 Thread via GitHub


diqiu50 commented on code in PR #5905:
URL: https://github.com/apache/gravitino/pull/5905#discussion_r1994571879


##
clients/filesystem-fuse/src/main.rs:
##
@@ -193,6 +213,33 @@ fn main() -> Result<(), i32> {
 path.to_string_lossy().to_string()
 };
 
+if env::var("RUST_LOG").is_ok() {
+init_tracing_subscriber(LevelFilter::INFO, "");
+} else {
+// if debug > 0, it means that we needs fuse_debug.
+app_config.fuse.fuse_debug = debug > 0 || 
app_config.fuse.fuse_debug;
+match debug {
+0 => {
+init_tracing_subscriber(LevelFilter::INFO, "");

Review Comment:
   Just care about debug==1  now



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]



Re: [PR] [#5873] feat(gvfs-fuse): add debug log for FuseApiHandle [gravitino]

2025-03-13 Thread via GitHub


diqiu50 commented on code in PR #5905:
URL: https://github.com/apache/gravitino/pull/5905#discussion_r1994574395


##
clients/filesystem-fuse/src/main.rs:
##
@@ -193,6 +213,33 @@ fn main() -> Result<(), i32> {
 path.to_string_lossy().to_string()
 };
 
+if env::var("RUST_LOG").is_ok() {
+init_tracing_subscriber(LevelFilter::INFO, "");
+} else {
+// if debug > 0, it means that we needs fuse_debug.
+app_config.fuse.fuse_debug = debug > 0 || 
app_config.fuse.fuse_debug;
+match debug {
+0 => {
+init_tracing_subscriber(LevelFilter::INFO, "");

Review Comment:
   The debug flag of gvfs-fuse only add the debug info for the gvfs-fuse. not 
other moudules



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]



Re: [PR] [#5873] feat(gvfs-fuse): add debug log for FuseApiHandle [gravitino]

2025-03-13 Thread via GitHub


diqiu50 commented on code in PR #5905:
URL: https://github.com/apache/gravitino/pull/5905#discussion_r1992619619


##
clients/filesystem-fuse/src/main.rs:
##
@@ -193,6 +213,33 @@ fn main() -> Result<(), i32> {
 path.to_string_lossy().to_string()
 };
 
+if env::var("RUST_LOG").is_ok() {
+init_tracing_subscriber(LevelFilter::INFO, "");
+} else {
+// if debug > 0, it means that we needs fuse_debug.
+app_config.fuse.fuse_debug = debug > 0 || 
app_config.fuse.fuse_debug;
+match debug {
+0 => {
+init_tracing_subscriber(LevelFilter::INFO, "");

Review Comment:
   I mean the whole `gvfs-fuse`



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]



Re: [PR] [#5873] feat(gvfs-fuse): add debug log for FuseApiHandle [gravitino]

2025-03-13 Thread via GitHub


unknowntpo commented on code in PR #5905:
URL: https://github.com/apache/gravitino/pull/5905#discussion_r1993255166


##
clients/filesystem-fuse/src/main.rs:
##
@@ -193,6 +213,33 @@ fn main() -> Result<(), i32> {
 path.to_string_lossy().to_string()
 };
 
+if env::var("RUST_LOG").is_ok() {
+init_tracing_subscriber(LevelFilter::INFO, "");
+} else {
+// if debug > 0, it means that we needs fuse_debug.
+app_config.fuse.fuse_debug = debug > 0 || 
app_config.fuse.fuse_debug;
+match debug {
+0 => {
+init_tracing_subscriber(LevelFilter::INFO, "");

Review Comment:
   But what's the plan for `debug > 1` ? should we enable more detail logging 
like `fuse_debug=trace` ? Or we just care about `debug==1` for now ?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]



Re: [PR] [#5873] feat(gvfs-fuse): add debug log for FuseApiHandle [gravitino]

2025-03-13 Thread via GitHub


unknowntpo commented on code in PR #5905:
URL: https://github.com/apache/gravitino/pull/5905#discussion_r1993253020


##
clients/filesystem-fuse/src/main.rs:
##
@@ -193,6 +213,33 @@ fn main() -> Result<(), i32> {
 path.to_string_lossy().to_string()
 };
 
+if env::var("RUST_LOG").is_ok() {
+init_tracing_subscriber(LevelFilter::INFO, "");
+} else {
+// if debug > 0, it means that we needs fuse_debug.
+app_config.fuse.fuse_debug = debug > 0 || 
app_config.fuse.fuse_debug;
+match debug {
+0 => {
+init_tracing_subscriber(LevelFilter::INFO, "");

Review Comment:
   Okay, so I think the spec will be:
   
   - When `debug == 0`, we use value of RUST_LOG as directives, the actual 
effect should be RUST_LOG="".
   - When `debug != 0`, we particularly we need to append `gvfs_fuse=debug` to 
the value of `RUST_LOG`, the actual effect should be 
`RUST_LOG=",gvfs_fuse=debug"`, this ensures that 
whatever the `RUST_LOG` is, `gvfs_fuse` still has debug level logging.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]



Re: [PR] [#5873] feat(gvfs-fuse): add debug log for FuseApiHandle [gravitino]

2025-03-12 Thread via GitHub


unknowntpo commented on code in PR #5905:
URL: https://github.com/apache/gravitino/pull/5905#discussion_r1992580883


##
clients/filesystem-fuse/src/main.rs:
##
@@ -193,6 +213,33 @@ fn main() -> Result<(), i32> {
 path.to_string_lossy().to_string()
 };
 
+if env::var("RUST_LOG").is_ok() {
+init_tracing_subscriber(LevelFilter::INFO, "");
+} else {
+// if debug > 0, it means that we needs fuse_debug.
+app_config.fuse.fuse_debug = debug > 0 || 
app_config.fuse.fuse_debug;
+match debug {
+0 => {
+init_tracing_subscriber(LevelFilter::INFO, "");

Review Comment:
   I ask this because at here,
   
   > 2. When the parameter debug != 0:
   • If RUST_LOG is set, use its value and append 
gvfs_fuse::fuse_api_handle_debug=debug without overriding RUST_LOG.
   
   you use the words `gvfs_fuse::fuse_api_handle_debug=debug`.
   
   but at here,
   
   > My point is that if the user sets RUST_LOG='info' and debug=1, the log 
level is equivalent to RUST_LOG="info, gvfs_fuse=debug".
   
   you use the word `gvfs_fuse=debug`
   
   you say `gvfs_fuse=debug`, does it mean the whole `gvfs_fuse` or just an 
abbreviation of `gvfs_fuse::fuse_api_handle_debug` ? 



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]



Re: [PR] [#5873] feat(gvfs-fuse): add debug log for FuseApiHandle [gravitino]

2025-03-12 Thread via GitHub


unknowntpo commented on code in PR #5905:
URL: https://github.com/apache/gravitino/pull/5905#discussion_r1992580732


##
clients/filesystem-fuse/src/main.rs:
##
@@ -193,6 +213,33 @@ fn main() -> Result<(), i32> {
 path.to_string_lossy().to_string()
 };
 
+if env::var("RUST_LOG").is_ok() {
+init_tracing_subscriber(LevelFilter::INFO, "");
+} else {
+// if debug > 0, it means that we needs fuse_debug.
+app_config.fuse.fuse_debug = debug > 0 || 
app_config.fuse.fuse_debug;
+match debug {
+0 => {
+init_tracing_subscriber(LevelFilter::INFO, "");

Review Comment:
   I want to list some examples to make sure my understanding is correct:
   
   1. When `debug` is not set, we use value of `RUST_LOG` as directives, the 
actual effect should be RUST_LOG="".
   2.  when `debug != 0`, we particularly we need to append 
`gvfs_fuse::fuse_api_handle_debug=debug` to the value of `RUST_LOG`, the actual 
effect should be 
`RUST_LOG=",gvfs_fuse::fuse_api_handle_debug=debug"`. 
This make sure that no matter which level is set by `RUST_LOG` for `gvfs_fuse`, 
`gvfs_fuse::fuse_api_handle_debug` still has debug level.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]



Re: [PR] [#5873] feat(gvfs-fuse): add debug log for FuseApiHandle [gravitino]

2025-03-12 Thread via GitHub


unknowntpo commented on code in PR #5905:
URL: https://github.com/apache/gravitino/pull/5905#discussion_r1992580732


##
clients/filesystem-fuse/src/main.rs:
##
@@ -193,6 +213,33 @@ fn main() -> Result<(), i32> {
 path.to_string_lossy().to_string()
 };
 
+if env::var("RUST_LOG").is_ok() {
+init_tracing_subscriber(LevelFilter::INFO, "");
+} else {
+// if debug > 0, it means that we needs fuse_debug.
+app_config.fuse.fuse_debug = debug > 0 || 
app_config.fuse.fuse_debug;
+match debug {
+0 => {
+init_tracing_subscriber(LevelFilter::INFO, "");

Review Comment:
   I want to list some examples to make sure my understanding is correct:
   
   1. When `debug` is not set, we use value of `RUST_LOG` as directives, the 
actual effect should be RUST_LOG="".
   2.  when `debug != 0`, we particularly we need to get the 
`gvfs_fuse::fuse_api_handle_debug=debug` and append to the value of `RUST_LOG`, 
the actual effect should be 
`RUST_LOG=",gvfs_fuse::fuse_api_handle_debug=debug"`, 
this make sure that no matter which level is set by `RUST_LOG` for `gvfs_fuse`, 
`gvfs_fuse::fuse_api_handle_debug` still has debug level.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]



Re: [PR] [#5873] feat(gvfs-fuse): add debug log for FuseApiHandle [gravitino]

2025-03-12 Thread via GitHub


diqiu50 commented on code in PR #5905:
URL: https://github.com/apache/gravitino/pull/5905#discussion_r1992705912


##
clients/filesystem-fuse/src/fuse_api_handle_debug.rs:
##
@@ -0,0 +1,829 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+use crate::config::AppConfig;
+use crate::filesystem::{FileSystemContext, RawFileSystem};
+use crate::fuse_api_handle::FuseApiHandle;
+use chrono::DateTime;
+use fuse3::path::prelude::{ReplyData, ReplyOpen, ReplyStatFs, ReplyWrite};
+use fuse3::path::Request;
+use fuse3::raw::prelude::{
+FileAttr, ReplyAttr, ReplyCreated, ReplyDirectory, ReplyDirectoryPlus, 
ReplyEntry, ReplyInit,
+};
+use fuse3::raw::reply::{DirectoryEntry, DirectoryEntryPlus};
+use fuse3::raw::Filesystem;
+use fuse3::{Inode, SetAttr, Timestamp};
+use futures_util::stream::{self, BoxStream};
+use futures_util::StreamExt;
+use std::ffi::OsStr;
+use std::fmt::Write;
+use tracing::{debug, error};
+
+/// Log the result without printing the reply
+macro_rules! log_status {
+($method_call:expr, $method_name:expr, $req:ident) => {
+match $method_call.await {
+Ok(reply) => {
+debug!($req.unique, "{} completed", 
$method_name.to_uppercase());
+Ok(reply)
+}
+Err(e) => {
+error!($req.unique, ?e, "{} failed", 
$method_name.to_uppercase());
+Err(e)
+}
+}
+};
+}
+
+/// Log the result with default Debug formatting
+macro_rules! log_value {
+($method_call:expr, $method_name:expr, $req:ident) => {
+match $method_call.await {
+Ok(reply) => {
+debug!(
+$req.unique,
+?reply,
+"{} completed",
+$method_name.to_uppercase()
+);
+Ok(reply)
+}
+Err(e) => {
+error!($req.unique, ?e, "{} failed", 
$method_name.to_uppercase());
+Err(e)
+}
+}
+};
+}
+
+/// Log the result with custom formatting
+macro_rules! log_value_custom {
+($method_call:expr, $method_name:expr, $req:ident, $format_reply_fn:ident) 
=> {
+match $method_call.await {
+Ok(reply) => {
+debug!(
+$req.unique,
+reply = $format_reply_fn(&reply),
+"{} completed",
+$method_name.to_uppercase()
+);
+Ok(reply)
+}
+Err(e) => {
+error!($req.unique, ?e, "{} failed", 
$method_name.to_uppercase());
+Err(e)
+}
+}
+};
+}
+
+/// Log the result for readdir operations
+macro_rules! log_readdir {
+($method_call:expr, $req:ident) => {{
+match $method_call.await {
+Ok(mut reply_dir) => {
+let mut entries = Vec::new();
+
+while let Some(entry_result) = reply_dir.entries.next().await {
+match entry_result {
+Ok(entry) => {
+entries.push(entry);
+}
+Err(e) => {
+return Err(e.into());
+}
+}
+}
+
+let entries_info = format!(
+"[{}]",
+entries
+.iter()
+.map(|entry| directory_entry_to_desc_str(entry))
+.collect::>()
+.join(", ")
+);
+
+debug!($req.unique, entries = entries_info, "READDIR 
completed");
+
+Ok(ReplyDirectory {
+entries: stream::iter(entries.into_iter().map(Ok)).boxed(),
+})
+}
+Err(e) => {
+error!($req.unique, ?e, "READDIR failed");
+Err(e)
+}
+}
+}};
+}
+
+/// Log the result for readdirplus operations
+macro_rules! log_readdirplus {
+($method_call:expr, $req:ident) => {{
+match $method_call.await {
+Ok(mut reply_dir

Re: [PR] [#5873] feat(gvfs-fuse): add debug log for FuseApiHandle [gravitino]

2025-03-12 Thread via GitHub


unknowntpo commented on code in PR #5905:
URL: https://github.com/apache/gravitino/pull/5905#discussion_r1992580732


##
clients/filesystem-fuse/src/main.rs:
##
@@ -193,6 +213,33 @@ fn main() -> Result<(), i32> {
 path.to_string_lossy().to_string()
 };
 
+if env::var("RUST_LOG").is_ok() {
+init_tracing_subscriber(LevelFilter::INFO, "");
+} else {
+// if debug > 0, it means that we needs fuse_debug.
+app_config.fuse.fuse_debug = debug > 0 || 
app_config.fuse.fuse_debug;
+match debug {
+0 => {
+init_tracing_subscriber(LevelFilter::INFO, "");

Review Comment:
   I want to list some examples to make sure my understanding is correct:
   
   1. When `debug == 0` t, we use value of `RUST_LOG` as directives, the actual 
effect should be RUST_LOG="".
   2.  when `debug != 0`, we particularly we need to append 
`gvfs_fuse::fuse_api_handle_debug=debug` to the value of `RUST_LOG`, the actual 
effect should be 
`RUST_LOG=",gvfs_fuse::fuse_api_handle_debug=debug"`. 
This make sure that no matter which level is set by `RUST_LOG` for `gvfs_fuse`, 
`gvfs_fuse::fuse_api_handle_debug` still has debug level.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]



Re: [PR] [#5873] feat(gvfs-fuse): add debug log for FuseApiHandle [gravitino]

2025-03-12 Thread via GitHub


unknowntpo commented on code in PR #5905:
URL: https://github.com/apache/gravitino/pull/5905#discussion_r1992580732


##
clients/filesystem-fuse/src/main.rs:
##
@@ -193,6 +213,33 @@ fn main() -> Result<(), i32> {
 path.to_string_lossy().to_string()
 };
 
+if env::var("RUST_LOG").is_ok() {
+init_tracing_subscriber(LevelFilter::INFO, "");
+} else {
+// if debug > 0, it means that we needs fuse_debug.
+app_config.fuse.fuse_debug = debug > 0 || 
app_config.fuse.fuse_debug;
+match debug {
+0 => {
+init_tracing_subscriber(LevelFilter::INFO, "");

Review Comment:
   I want to list some examples to make sure my understanding is correct:
   
   1. When `debug` is not set, we use value of `RUST_LOG` as directives, the 
actual effect should be RUST_LOG="".
   2.  when `debug != 0`, we particularly we need to get the 
`gvfs_fuse::fuse_api_handle_debug=debug` and append to the value of `RUST_LOG`, 
the actual effect should be 
`RUST_LOG=",gvfs_fuse::fuse_api_handle_debug=debug"`. 
This make sure that no matter which level is set by `RUST_LOG` for `gvfs_fuse`, 
`gvfs_fuse::fuse_api_handle_debug` still has debug level.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]



Re: [PR] [#5873] feat(gvfs-fuse): add debug log for FuseApiHandle [gravitino]

2025-03-12 Thread via GitHub


unknowntpo commented on code in PR #5905:
URL: https://github.com/apache/gravitino/pull/5905#discussion_r1992580553


##
clients/filesystem-fuse/src/main.rs:
##
@@ -193,6 +213,33 @@ fn main() -> Result<(), i32> {
 path.to_string_lossy().to_string()
 };
 
+if env::var("RUST_LOG").is_ok() {
+init_tracing_subscriber(LevelFilter::INFO, "");
+} else {
+// if debug > 0, it means that we needs fuse_debug.
+app_config.fuse.fuse_debug = debug > 0 || 
app_config.fuse.fuse_debug;
+match debug {
+0 => {
+init_tracing_subscriber(LevelFilter::INFO, "");

Review Comment:
   So the purpose of `debug` flag is for controlling the debug level of the 
**whole** `gvfs_fuse` package, right ? And for `debug=1`, we now enable 
`gvfs_fuse::fuse_api_handle_debug=debug`.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]



Re: [PR] [#5873] feat(gvfs-fuse): add debug log for FuseApiHandle [gravitino]

2025-03-12 Thread via GitHub


diqiu50 commented on code in PR #5905:
URL: https://github.com/apache/gravitino/pull/5905#discussion_r1991017228


##
clients/filesystem-fuse/src/main.rs:
##
@@ -193,6 +213,33 @@ fn main() -> Result<(), i32> {
 path.to_string_lossy().to_string()
 };
 
+if env::var("RUST_LOG").is_ok() {
+init_tracing_subscriber(LevelFilter::INFO, "");
+} else {
+// if debug > 0, it means that we needs fuse_debug.
+app_config.fuse.fuse_debug = debug > 0 || 
app_config.fuse.fuse_debug;
+match debug {
+0 => {
+init_tracing_subscriber(LevelFilter::INFO, "");

Review Comment:
   That is to say, the default behavior of the Log module remains unchanged. 
When debug=1, if the log level of gvfs_fuse is higher than debug, 
gvfs_fuse=debug is appended, and FuseApiHandleDebug is enabled.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]



Re: [PR] [#5873] feat(gvfs-fuse): add debug log for FuseApiHandle [gravitino]

2025-03-11 Thread via GitHub


unknowntpo commented on PR #5905:
URL: https://github.com/apache/gravitino/pull/5905#issuecomment-2716161989

   > @unknowntpo Thank you ,this PR is almost ready, just a few minor issues 
left. I'm sorry, I have been working on a project with a tight schedule. If the 
review is not timely, you can @ me on Slack.
   
   Really appreciate that you spent time to review my code! 
   Ok~ I'll mention you in slack.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]



Re: [PR] [#5873] feat(gvfs-fuse): add debug log for FuseApiHandle [gravitino]

2025-03-11 Thread via GitHub


unknowntpo commented on code in PR #5905:
URL: https://github.com/apache/gravitino/pull/5905#discussion_r1990398584


##
clients/filesystem-fuse/src/fuse_api_handle_debug.rs:
##
@@ -0,0 +1,829 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+use crate::config::AppConfig;
+use crate::filesystem::{FileSystemContext, RawFileSystem};
+use crate::fuse_api_handle::FuseApiHandle;
+use chrono::DateTime;
+use fuse3::path::prelude::{ReplyData, ReplyOpen, ReplyStatFs, ReplyWrite};
+use fuse3::path::Request;
+use fuse3::raw::prelude::{
+FileAttr, ReplyAttr, ReplyCreated, ReplyDirectory, ReplyDirectoryPlus, 
ReplyEntry, ReplyInit,
+};
+use fuse3::raw::reply::{DirectoryEntry, DirectoryEntryPlus};
+use fuse3::raw::Filesystem;
+use fuse3::{Inode, SetAttr, Timestamp};
+use futures_util::stream::{self, BoxStream};
+use futures_util::StreamExt;
+use std::ffi::OsStr;
+use std::fmt::Write;
+use tracing::{debug, error};
+
+/// Log the result without printing the reply
+macro_rules! log_status {
+($method_call:expr, $method_name:expr, $req:ident) => {
+match $method_call.await {
+Ok(reply) => {
+debug!($req.unique, "{} completed", 
$method_name.to_uppercase());
+Ok(reply)
+}
+Err(e) => {
+error!($req.unique, ?e, "{} failed", 
$method_name.to_uppercase());
+Err(e)
+}
+}
+};
+}
+
+/// Log the result with default Debug formatting
+macro_rules! log_value {
+($method_call:expr, $method_name:expr, $req:ident) => {
+match $method_call.await {
+Ok(reply) => {
+debug!(
+$req.unique,
+?reply,
+"{} completed",
+$method_name.to_uppercase()
+);
+Ok(reply)
+}
+Err(e) => {
+error!($req.unique, ?e, "{} failed", 
$method_name.to_uppercase());
+Err(e)
+}
+}
+};
+}
+
+/// Log the result with custom formatting
+macro_rules! log_value_custom {
+($method_call:expr, $method_name:expr, $req:ident, $format_reply_fn:ident) 
=> {
+match $method_call.await {
+Ok(reply) => {
+debug!(
+$req.unique,
+reply = $format_reply_fn(&reply),
+"{} completed",
+$method_name.to_uppercase()
+);
+Ok(reply)
+}
+Err(e) => {
+error!($req.unique, ?e, "{} failed", 
$method_name.to_uppercase());
+Err(e)
+}
+}
+};
+}
+
+/// Log the result for readdir operations
+macro_rules! log_readdir {
+($method_call:expr, $req:ident) => {{
+match $method_call.await {
+Ok(mut reply_dir) => {
+let mut entries = Vec::new();
+
+while let Some(entry_result) = reply_dir.entries.next().await {
+match entry_result {
+Ok(entry) => {
+entries.push(entry);
+}
+Err(e) => {
+return Err(e.into());
+}
+}
+}
+
+let entries_info = format!(
+"[{}]",
+entries
+.iter()
+.map(|entry| directory_entry_to_desc_str(entry))
+.collect::>()
+.join(", ")
+);
+
+debug!($req.unique, entries = entries_info, "READDIR 
completed");
+
+Ok(ReplyDirectory {
+entries: stream::iter(entries.into_iter().map(Ok)).boxed(),
+})
+}
+Err(e) => {
+error!($req.unique, ?e, "READDIR failed");
+Err(e)
+}
+}
+}};
+}
+
+/// Log the result for readdirplus operations
+macro_rules! log_readdirplus {
+($method_call:expr, $req:ident) => {{
+match $method_call.await {
+Ok(mut reply_

Re: [PR] [#5873] feat(gvfs-fuse): add debug log for FuseApiHandle [gravitino]

2025-03-11 Thread via GitHub


unknowntpo commented on code in PR #5905:
URL: https://github.com/apache/gravitino/pull/5905#discussion_r1990391628


##
clients/filesystem-fuse/src/main.rs:
##
@@ -193,6 +213,33 @@ fn main() -> Result<(), i32> {
 path.to_string_lossy().to_string()
 };
 
+if env::var("RUST_LOG").is_ok() {
+init_tracing_subscriber(LevelFilter::INFO, "");
+} else {
+// if debug > 0, it means that we needs fuse_debug.
+app_config.fuse.fuse_debug = debug > 0 || 
app_config.fuse.fuse_debug;
+match debug {
+0 => {
+init_tracing_subscriber(LevelFilter::INFO, "");

Review Comment:
   @diqiu50 
   
   I have a question:
   
   1. Does your statements implies that:
   
   - if `debug == 0`:
 - use `RUST_LOG`'s value as directives.
   - if `debug != 0`:
 - if `RUST_LOG` has value, then the directive becomes: 
`,gvfs_fuse::fuse_api_handle_debug=debug` ?
 - if `RUST_LOG` is not set, we simply set directives as 
`gvfs_fuse::fuse_api_handle_debug=debug` ?
   
   What I not quite sure is:
   
   > 2. When the parameter debug != 0:
   • If RUST_LOG is set, use its value and append 
gvfs_fuse::fuse_api_handle_debug=debug without overriding RUST_LOG.
   
   Does this means that if `debug != 0`, whatever RUST_LOG value is, we just 
set `gvfs_fuse::fuse_api_handle_debug` as debug level ?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]



Re: [PR] [#5873] feat(gvfs-fuse): add debug log for FuseApiHandle [gravitino]

2025-03-11 Thread via GitHub


diqiu50 commented on code in PR #5905:
URL: https://github.com/apache/gravitino/pull/5905#discussion_r1986547245


##
clients/filesystem-fuse/src/main.rs:
##
@@ -193,6 +213,33 @@ fn main() -> Result<(), i32> {
 path.to_string_lossy().to_string()
 };
 
+if env::var("RUST_LOG").is_ok() {
+init_tracing_subscriber(LevelFilter::INFO, "");
+} else {
+// if debug > 0, it means that we needs fuse_debug.
+app_config.fuse.fuse_debug = debug > 0 || 
app_config.fuse.fuse_debug;
+match debug {
+0 => {
+init_tracing_subscriber(LevelFilter::INFO, "");

Review Comment:
   The level 0 is default. same as using `RUST_LOG`



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]



Re: [PR] [#5873] feat(gvfs-fuse): add debug log for FuseApiHandle [gravitino]

2025-03-09 Thread via GitHub


diqiu50 commented on code in PR #5905:
URL: https://github.com/apache/gravitino/pull/5905#discussion_r1986554343


##
clients/filesystem-fuse/src/main.rs:
##
@@ -193,6 +213,33 @@ fn main() -> Result<(), i32> {
 path.to_string_lossy().to_string()
 };
 
+if env::var("RUST_LOG").is_ok() {
+init_tracing_subscriber(LevelFilter::INFO, "");
+} else {
+// if debug > 0, it means that we needs fuse_debug.
+app_config.fuse.fuse_debug = debug > 0 || 
app_config.fuse.fuse_debug;
+match debug {
+0 => {
+init_tracing_subscriber(LevelFilter::INFO, "");

Review Comment:
   What needs to be done here:
1.  RUST_LOG should control the global logging behavior. We should 
not override RUST_LOG.
2.  When the parameter debug != 0:
•   If RUST_LOG is set, use its value and append 
gvfs_fuse::fuse_api_handle_debug=debug without overriding RUST_LOG.
•   Example: If RUST_LOG=trace, keep the trace level and just 
enable FuseApiHandleDebug. If RUST_LOG=info, set 
gvfs_fuse::fuse_api_handle_debug=debug along with the original RUST_LOG 
setting, ensuring that FuseApiHandleDebug is enabled.
   
   This ensures that RUST_LOG’s original behavior is preserved while 
dynamically enabling FuseApiHandleDebug.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]



Re: [PR] [#5873] feat(gvfs-fuse): add debug log for FuseApiHandle [gravitino]

2025-03-09 Thread via GitHub


diqiu50 commented on PR #5905:
URL: https://github.com/apache/gravitino/pull/5905#issuecomment-2709345411

   @unknowntpo Thank you ,this PR is almost ready, just a few minor issues 
left. 
I'm sorry, I have been working on a project with a tight schedule. If the 
review is not timely, you can @ me on Slack. 


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]



Re: [PR] [#5873] feat(gvfs-fuse): add debug log for FuseApiHandle [gravitino]

2025-03-09 Thread via GitHub


diqiu50 commented on code in PR #5905:
URL: https://github.com/apache/gravitino/pull/5905#discussion_r1986546189


##
clients/filesystem-fuse/src/main.rs:
##
@@ -193,6 +213,33 @@ fn main() -> Result<(), i32> {
 path.to_string_lossy().to_string()
 };
 
+if env::var("RUST_LOG").is_ok() {
+init_tracing_subscriber(LevelFilter::INFO, "");

Review Comment:
   We should not override the logging behavior controlled by `RUST_LOG`.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]



Re: [PR] [#5873] feat(gvfs-fuse): add debug log for FuseApiHandle [gravitino]

2025-03-05 Thread via GitHub


diqiu50 commented on code in PR #5905:
URL: https://github.com/apache/gravitino/pull/5905#discussion_r1982603884


##
clients/filesystem-fuse/src/fuse_api_handle_debug.rs:
##
@@ -0,0 +1,829 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+use crate::config::AppConfig;
+use crate::filesystem::{FileSystemContext, RawFileSystem};
+use crate::fuse_api_handle::FuseApiHandle;
+use chrono::DateTime;
+use fuse3::path::prelude::{ReplyData, ReplyOpen, ReplyStatFs, ReplyWrite};
+use fuse3::path::Request;
+use fuse3::raw::prelude::{
+FileAttr, ReplyAttr, ReplyCreated, ReplyDirectory, ReplyDirectoryPlus, 
ReplyEntry, ReplyInit,
+};
+use fuse3::raw::reply::{DirectoryEntry, DirectoryEntryPlus};
+use fuse3::raw::Filesystem;
+use fuse3::{Inode, SetAttr, Timestamp};
+use futures_util::stream::{self, BoxStream};
+use futures_util::StreamExt;
+use std::ffi::OsStr;
+use std::fmt::Write;
+use tracing::{debug, error};
+
+/// Log the result without printing the reply
+macro_rules! log_status {
+($method_call:expr, $method_name:expr, $req:ident) => {
+match $method_call.await {
+Ok(reply) => {
+debug!($req.unique, "{} completed", 
$method_name.to_uppercase());
+Ok(reply)
+}
+Err(e) => {
+error!($req.unique, ?e, "{} failed", 
$method_name.to_uppercase());
+Err(e)
+}
+}
+};
+}
+
+/// Log the result with default Debug formatting
+macro_rules! log_value {
+($method_call:expr, $method_name:expr, $req:ident) => {
+match $method_call.await {
+Ok(reply) => {
+debug!(
+$req.unique,
+?reply,
+"{} completed",
+$method_name.to_uppercase()
+);
+Ok(reply)
+}
+Err(e) => {
+error!($req.unique, ?e, "{} failed", 
$method_name.to_uppercase());
+Err(e)
+}
+}
+};
+}
+
+/// Log the result with custom formatting
+macro_rules! log_value_custom {
+($method_call:expr, $method_name:expr, $req:ident, $format_reply_fn:ident) 
=> {
+match $method_call.await {
+Ok(reply) => {
+debug!(
+$req.unique,
+reply = $format_reply_fn(&reply),
+"{} completed",
+$method_name.to_uppercase()
+);
+Ok(reply)
+}
+Err(e) => {
+error!($req.unique, ?e, "{} failed", 
$method_name.to_uppercase());
+Err(e)
+}
+}
+};
+}
+
+/// Log the result for readdir operations
+macro_rules! log_readdir {
+($method_call:expr, $req:ident) => {{
+match $method_call.await {
+Ok(mut reply_dir) => {
+let mut entries = Vec::new();
+
+while let Some(entry_result) = reply_dir.entries.next().await {
+match entry_result {
+Ok(entry) => {
+entries.push(entry);
+}
+Err(e) => {
+return Err(e.into());
+}
+}
+}
+
+let entries_info = format!(
+"[{}]",
+entries
+.iter()
+.map(|entry| directory_entry_to_desc_str(entry))
+.collect::>()
+.join(", ")
+);
+
+debug!($req.unique, entries = entries_info, "READDIR 
completed");
+
+Ok(ReplyDirectory {
+entries: stream::iter(entries.into_iter().map(Ok)).boxed(),
+})
+}
+Err(e) => {
+error!($req.unique, ?e, "READDIR failed");
+Err(e)
+}
+}
+}};
+}
+
+/// Log the result for readdirplus operations
+macro_rules! log_readdirplus {
+($method_call:expr, $req:ident) => {{
+match $method_call.await {
+Ok(mut reply_dir

Re: [PR] [#5873] feat(gvfs-fuse): add debug log for FuseApiHandle [gravitino]

2025-03-03 Thread via GitHub


unknowntpo commented on code in PR #5905:
URL: https://github.com/apache/gravitino/pull/5905#discussion_r1978575447


##
clients/filesystem-fuse/src/fuse_api_handle_debug.rs:
##
@@ -0,0 +1,871 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+use crate::config::AppConfig;
+use crate::filesystem::{FileSystemContext, RawFileSystem};
+use crate::fuse_api_handle::FuseApiHandle;
+use chrono::DateTime;
+use fuse3::path::prelude::{ReplyData, ReplyOpen, ReplyStatFs, ReplyWrite};
+use fuse3::path::Request;
+use fuse3::raw::prelude::{
+FileAttr, ReplyAttr, ReplyCreated, ReplyDirectory, ReplyDirectoryPlus, 
ReplyEntry, ReplyInit,
+};
+use fuse3::raw::reply::{DirectoryEntry, DirectoryEntryPlus};
+use fuse3::raw::Filesystem;
+use fuse3::{Inode, SetAttr, Timestamp};
+use futures_util::stream::{self, BoxStream};
+use futures_util::StreamExt;
+use std::ffi::OsStr;
+use std::fmt::Write;
+use tracing::{debug, error};
+
+/// A macro to log the result of an asynchronous method call in the context of 
FUSE operations.
+///
+/// This macro provides six variants for logging:
+/// 1. Without logging the reply (logs only the method status).
+/// 2. With default `Debug` formatting for the reply.
+/// 3. With a customizable formatting function for the reply.
+/// 4. With both Debug and custom formatting for the reply.
+/// 5. Special stream handling for `readdir` operations.
+/// 6. Special stream handling for `readdirplus` operations.
+///
+/// # Usage
+///
+/// ```ignore
+/// // No reply printing
+/// log_result!(method_call, "method_name", req);
+///
+/// // With default Debug formatting for the reply
+/// log_result!(method_call, "method_name", req, debug);
+///
+/// // With a custom formatting function for the reply
+/// log_result!(method_call, "method_name", req, custom_format_fn);
+///
+/// // With both Debug and custom formatting
+/// log_result!(method_call, "method_name", req, debug, custom_format_fn);
+///
+/// // Special handling for readdir stream
+/// log_result!(method_call, "readdir", req, stream);
+///
+/// // Special handling for readdirplus stream
+/// log_result!(method_call, "readdirplus", req, stream);
+/// ```
+///
+/// # Arguments
+///
+/// * `$method_call` - The asynchronous method call to execute and log.
+/// * `$method_name` - A string representing the name of the method for 
logging purposes.
+/// * `$req` - The incoming FUSE request associated with the method call.
+/// * Format Options (Optional):
+/// * No format option - Only logs method status
+/// * `debug` - Uses default Debug formatting for the reply
+/// * (`debug`, custom_format_fn) - Combines Debug output with custom 
formatted output
+/// * `stream` - Special handling for directory streams (only for 
"readdir"/"readdirplus")
+macro_rules! log_result {
+// No reply printing
+($method_call:expr, $method_name:expr, $req:ident) => {
+match $method_call.await {
+Ok(reply) => {
+debug!($req.unique, "{} completed", 
$method_name.to_uppercase());
+Ok(reply)
+}
+Err(e) => {
+error!($req.unique, ?e, "{} failed", 
$method_name.to_uppercase());
+Err(e)
+}
+}
+};
+
+// Default Debug formatting
+($method_call:expr, $method_name:expr, $req:ident, debug) => {
+match $method_call.await {
+Ok(reply) => {
+debug!(
+$req.unique,
+?reply,
+"{} completed",
+$method_name.to_uppercase()
+);
+Ok(reply)
+}
+Err(e) => {
+error!($req.unique, ?e, "{} failed", 
$method_name.to_uppercase());
+Err(e)
+}
+}
+};
+
+// Format stream for readdir
+($method_call:expr, "readdir", $req:ident, stream) => {{
+match $method_call.await {
+Ok(mut reply_dir) => {
+let mut entries = Vec::new();
+
+while let Some(entry_result) = reply_dir.entries.next().await {
+match entry_result {
+Ok(entry) => {
+ 

Re: [PR] [#5873] feat(gvfs-fuse): add debug log for FuseApiHandle [gravitino]

2025-03-03 Thread via GitHub


unknowntpo commented on code in PR #5905:
URL: https://github.com/apache/gravitino/pull/5905#discussion_r1978575688


##
clients/filesystem-fuse/src/fuse_api_handle_debug.rs:
##
@@ -0,0 +1,871 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+use crate::config::AppConfig;
+use crate::filesystem::{FileSystemContext, RawFileSystem};
+use crate::fuse_api_handle::FuseApiHandle;
+use chrono::DateTime;
+use fuse3::path::prelude::{ReplyData, ReplyOpen, ReplyStatFs, ReplyWrite};
+use fuse3::path::Request;
+use fuse3::raw::prelude::{
+FileAttr, ReplyAttr, ReplyCreated, ReplyDirectory, ReplyDirectoryPlus, 
ReplyEntry, ReplyInit,
+};
+use fuse3::raw::reply::{DirectoryEntry, DirectoryEntryPlus};
+use fuse3::raw::Filesystem;
+use fuse3::{Inode, SetAttr, Timestamp};
+use futures_util::stream::{self, BoxStream};
+use futures_util::StreamExt;
+use std::ffi::OsStr;
+use std::fmt::Write;
+use tracing::{debug, error};
+
+/// A macro to log the result of an asynchronous method call in the context of 
FUSE operations.
+///
+/// This macro provides six variants for logging:
+/// 1. Without logging the reply (logs only the method status).
+/// 2. With default `Debug` formatting for the reply.
+/// 3. With a customizable formatting function for the reply.
+/// 4. With both Debug and custom formatting for the reply.
+/// 5. Special stream handling for `readdir` operations.
+/// 6. Special stream handling for `readdirplus` operations.
+///
+/// # Usage
+///
+/// ```ignore
+/// // No reply printing
+/// log_result!(method_call, "method_name", req);
+///
+/// // With default Debug formatting for the reply
+/// log_result!(method_call, "method_name", req, debug);

Review Comment:
   Ok, Done.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]



Re: [PR] [#5873] feat(gvfs-fuse): add debug log for FuseApiHandle [gravitino]

2025-03-03 Thread via GitHub


diqiu50 commented on code in PR #5905:
URL: https://github.com/apache/gravitino/pull/5905#discussion_r1977053414


##
clients/filesystem-fuse/src/fuse_api_handle_debug.rs:
##
@@ -0,0 +1,871 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+use crate::config::AppConfig;
+use crate::filesystem::{FileSystemContext, RawFileSystem};
+use crate::fuse_api_handle::FuseApiHandle;
+use chrono::DateTime;
+use fuse3::path::prelude::{ReplyData, ReplyOpen, ReplyStatFs, ReplyWrite};
+use fuse3::path::Request;
+use fuse3::raw::prelude::{
+FileAttr, ReplyAttr, ReplyCreated, ReplyDirectory, ReplyDirectoryPlus, 
ReplyEntry, ReplyInit,
+};
+use fuse3::raw::reply::{DirectoryEntry, DirectoryEntryPlus};
+use fuse3::raw::Filesystem;
+use fuse3::{Inode, SetAttr, Timestamp};
+use futures_util::stream::{self, BoxStream};
+use futures_util::StreamExt;
+use std::ffi::OsStr;
+use std::fmt::Write;
+use tracing::{debug, error};
+
+/// A macro to log the result of an asynchronous method call in the context of 
FUSE operations.
+///
+/// This macro provides six variants for logging:
+/// 1. Without logging the reply (logs only the method status).
+/// 2. With default `Debug` formatting for the reply.
+/// 3. With a customizable formatting function for the reply.
+/// 4. With both Debug and custom formatting for the reply.
+/// 5. Special stream handling for `readdir` operations.
+/// 6. Special stream handling for `readdirplus` operations.
+///
+/// # Usage
+///
+/// ```ignore
+/// // No reply printing
+/// log_result!(method_call, "method_name", req);
+///
+/// // With default Debug formatting for the reply
+/// log_result!(method_call, "method_name", req, debug);
+///
+/// // With a custom formatting function for the reply
+/// log_result!(method_call, "method_name", req, custom_format_fn);
+///
+/// // With both Debug and custom formatting
+/// log_result!(method_call, "method_name", req, debug, custom_format_fn);
+///
+/// // Special handling for readdir stream
+/// log_result!(method_call, "readdir", req, stream);
+///
+/// // Special handling for readdirplus stream
+/// log_result!(method_call, "readdirplus", req, stream);
+/// ```
+///
+/// # Arguments
+///
+/// * `$method_call` - The asynchronous method call to execute and log.
+/// * `$method_name` - A string representing the name of the method for 
logging purposes.
+/// * `$req` - The incoming FUSE request associated with the method call.
+/// * Format Options (Optional):
+/// * No format option - Only logs method status
+/// * `debug` - Uses default Debug formatting for the reply
+/// * (`debug`, custom_format_fn) - Combines Debug output with custom 
formatted output
+/// * `stream` - Special handling for directory streams (only for 
"readdir"/"readdirplus")
+macro_rules! log_result {
+// No reply printing
+($method_call:expr, $method_name:expr, $req:ident) => {
+match $method_call.await {
+Ok(reply) => {
+debug!($req.unique, "{} completed", 
$method_name.to_uppercase());
+Ok(reply)
+}
+Err(e) => {
+error!($req.unique, ?e, "{} failed", 
$method_name.to_uppercase());
+Err(e)
+}
+}
+};
+
+// Default Debug formatting
+($method_call:expr, $method_name:expr, $req:ident, debug) => {
+match $method_call.await {
+Ok(reply) => {
+debug!(
+$req.unique,
+?reply,
+"{} completed",
+$method_name.to_uppercase()
+);
+Ok(reply)
+}
+Err(e) => {
+error!($req.unique, ?e, "{} failed", 
$method_name.to_uppercase());
+Err(e)
+}
+}
+};
+
+// Format stream for readdir
+($method_call:expr, "readdir", $req:ident, stream) => {{
+match $method_call.await {
+Ok(mut reply_dir) => {
+let mut entries = Vec::new();
+
+while let Some(entry_result) = reply_dir.entries.next().await {
+match entry_result {
+Ok(entry) => {
+

Re: [PR] [#5873] feat(gvfs-fuse): add debug log for FuseApiHandle [gravitino]

2025-03-03 Thread via GitHub


diqiu50 commented on code in PR #5905:
URL: https://github.com/apache/gravitino/pull/5905#discussion_r1977053414


##
clients/filesystem-fuse/src/fuse_api_handle_debug.rs:
##
@@ -0,0 +1,871 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+use crate::config::AppConfig;
+use crate::filesystem::{FileSystemContext, RawFileSystem};
+use crate::fuse_api_handle::FuseApiHandle;
+use chrono::DateTime;
+use fuse3::path::prelude::{ReplyData, ReplyOpen, ReplyStatFs, ReplyWrite};
+use fuse3::path::Request;
+use fuse3::raw::prelude::{
+FileAttr, ReplyAttr, ReplyCreated, ReplyDirectory, ReplyDirectoryPlus, 
ReplyEntry, ReplyInit,
+};
+use fuse3::raw::reply::{DirectoryEntry, DirectoryEntryPlus};
+use fuse3::raw::Filesystem;
+use fuse3::{Inode, SetAttr, Timestamp};
+use futures_util::stream::{self, BoxStream};
+use futures_util::StreamExt;
+use std::ffi::OsStr;
+use std::fmt::Write;
+use tracing::{debug, error};
+
+/// A macro to log the result of an asynchronous method call in the context of 
FUSE operations.
+///
+/// This macro provides six variants for logging:
+/// 1. Without logging the reply (logs only the method status).
+/// 2. With default `Debug` formatting for the reply.
+/// 3. With a customizable formatting function for the reply.
+/// 4. With both Debug and custom formatting for the reply.
+/// 5. Special stream handling for `readdir` operations.
+/// 6. Special stream handling for `readdirplus` operations.
+///
+/// # Usage
+///
+/// ```ignore
+/// // No reply printing
+/// log_result!(method_call, "method_name", req);
+///
+/// // With default Debug formatting for the reply
+/// log_result!(method_call, "method_name", req, debug);
+///
+/// // With a custom formatting function for the reply
+/// log_result!(method_call, "method_name", req, custom_format_fn);
+///
+/// // With both Debug and custom formatting
+/// log_result!(method_call, "method_name", req, debug, custom_format_fn);
+///
+/// // Special handling for readdir stream
+/// log_result!(method_call, "readdir", req, stream);
+///
+/// // Special handling for readdirplus stream
+/// log_result!(method_call, "readdirplus", req, stream);
+/// ```
+///
+/// # Arguments
+///
+/// * `$method_call` - The asynchronous method call to execute and log.
+/// * `$method_name` - A string representing the name of the method for 
logging purposes.
+/// * `$req` - The incoming FUSE request associated with the method call.
+/// * Format Options (Optional):
+/// * No format option - Only logs method status
+/// * `debug` - Uses default Debug formatting for the reply
+/// * (`debug`, custom_format_fn) - Combines Debug output with custom 
formatted output
+/// * `stream` - Special handling for directory streams (only for 
"readdir"/"readdirplus")
+macro_rules! log_result {
+// No reply printing
+($method_call:expr, $method_name:expr, $req:ident) => {
+match $method_call.await {
+Ok(reply) => {
+debug!($req.unique, "{} completed", 
$method_name.to_uppercase());
+Ok(reply)
+}
+Err(e) => {
+error!($req.unique, ?e, "{} failed", 
$method_name.to_uppercase());
+Err(e)
+}
+}
+};
+
+// Default Debug formatting
+($method_call:expr, $method_name:expr, $req:ident, debug) => {
+match $method_call.await {
+Ok(reply) => {
+debug!(
+$req.unique,
+?reply,
+"{} completed",
+$method_name.to_uppercase()
+);
+Ok(reply)
+}
+Err(e) => {
+error!($req.unique, ?e, "{} failed", 
$method_name.to_uppercase());
+Err(e)
+}
+}
+};
+
+// Format stream for readdir
+($method_call:expr, "readdir", $req:ident, stream) => {{
+match $method_call.await {
+Ok(mut reply_dir) => {
+let mut entries = Vec::new();
+
+while let Some(entry_result) = reply_dir.entries.next().await {
+match entry_result {
+Ok(entry) => {
+

Re: [PR] [#5873] feat(gvfs-fuse): add debug log for FuseApiHandle [gravitino]

2025-03-01 Thread via GitHub


unknowntpo commented on code in PR #5905:
URL: https://github.com/apache/gravitino/pull/5905#discussion_r1976515011


##
clients/filesystem-fuse/src/fuse_api_handle_debug.rs:
##
@@ -0,0 +1,871 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+use crate::config::AppConfig;
+use crate::filesystem::{FileSystemContext, RawFileSystem};
+use crate::fuse_api_handle::FuseApiHandle;
+use chrono::DateTime;
+use fuse3::path::prelude::{ReplyData, ReplyOpen, ReplyStatFs, ReplyWrite};
+use fuse3::path::Request;
+use fuse3::raw::prelude::{
+FileAttr, ReplyAttr, ReplyCreated, ReplyDirectory, ReplyDirectoryPlus, 
ReplyEntry, ReplyInit,
+};
+use fuse3::raw::reply::{DirectoryEntry, DirectoryEntryPlus};
+use fuse3::raw::Filesystem;
+use fuse3::{Inode, SetAttr, Timestamp};
+use futures_util::stream::{self, BoxStream};
+use futures_util::StreamExt;
+use std::ffi::OsStr;
+use std::fmt::Write;
+use tracing::{debug, error};
+
+/// A macro to log the result of an asynchronous method call in the context of 
FUSE operations.
+///
+/// This macro provides six variants for logging:
+/// 1. Without logging the reply (logs only the method status).
+/// 2. With default `Debug` formatting for the reply.
+/// 3. With a customizable formatting function for the reply.
+/// 4. With both Debug and custom formatting for the reply.
+/// 5. Special stream handling for `readdir` operations.
+/// 6. Special stream handling for `readdirplus` operations.
+///
+/// # Usage
+///
+/// ```ignore
+/// // No reply printing
+/// log_result!(method_call, "method_name", req);
+///
+/// // With default Debug formatting for the reply
+/// log_result!(method_call, "method_name", req, debug);
+///
+/// // With a custom formatting function for the reply
+/// log_result!(method_call, "method_name", req, custom_format_fn);
+///
+/// // With both Debug and custom formatting
+/// log_result!(method_call, "method_name", req, debug, custom_format_fn);
+///
+/// // Special handling for readdir stream
+/// log_result!(method_call, "readdir", req, stream);
+///
+/// // Special handling for readdirplus stream
+/// log_result!(method_call, "readdirplus", req, stream);
+/// ```
+///
+/// # Arguments
+///
+/// * `$method_call` - The asynchronous method call to execute and log.
+/// * `$method_name` - A string representing the name of the method for 
logging purposes.
+/// * `$req` - The incoming FUSE request associated with the method call.
+/// * Format Options (Optional):
+/// * No format option - Only logs method status
+/// * `debug` - Uses default Debug formatting for the reply
+/// * (`debug`, custom_format_fn) - Combines Debug output with custom 
formatted output
+/// * `stream` - Special handling for directory streams (only for 
"readdir"/"readdirplus")
+macro_rules! log_result {
+// No reply printing
+($method_call:expr, $method_name:expr, $req:ident) => {
+match $method_call.await {
+Ok(reply) => {
+debug!($req.unique, "{} completed", 
$method_name.to_uppercase());
+Ok(reply)
+}
+Err(e) => {
+error!($req.unique, ?e, "{} failed", 
$method_name.to_uppercase());
+Err(e)
+}
+}
+};
+
+// Default Debug formatting
+($method_call:expr, $method_name:expr, $req:ident, debug) => {
+match $method_call.await {
+Ok(reply) => {
+debug!(
+$req.unique,
+?reply,
+"{} completed",
+$method_name.to_uppercase()
+);
+Ok(reply)
+}
+Err(e) => {
+error!($req.unique, ?e, "{} failed", 
$method_name.to_uppercase());
+Err(e)
+}
+}
+};
+
+// Format stream for readdir
+($method_call:expr, "readdir", $req:ident, stream) => {{
+match $method_call.await {
+Ok(mut reply_dir) => {
+let mut entries = Vec::new();
+
+while let Some(entry_result) = reply_dir.entries.next().await {
+match entry_result {
+Ok(entry) => {
+ 

Re: [PR] [#5873] feat(gvfs-fuse): add debug log for FuseApiHandle [gravitino]

2025-02-26 Thread via GitHub


diqiu50 commented on code in PR #5905:
URL: https://github.com/apache/gravitino/pull/5905#discussion_r1972734422


##
clients/filesystem-fuse/src/fuse_api_handle_debug.rs:
##
@@ -0,0 +1,871 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+use crate::config::AppConfig;
+use crate::filesystem::{FileSystemContext, RawFileSystem};
+use crate::fuse_api_handle::FuseApiHandle;
+use chrono::DateTime;
+use fuse3::path::prelude::{ReplyData, ReplyOpen, ReplyStatFs, ReplyWrite};
+use fuse3::path::Request;
+use fuse3::raw::prelude::{
+FileAttr, ReplyAttr, ReplyCreated, ReplyDirectory, ReplyDirectoryPlus, 
ReplyEntry, ReplyInit,
+};
+use fuse3::raw::reply::{DirectoryEntry, DirectoryEntryPlus};
+use fuse3::raw::Filesystem;
+use fuse3::{Inode, SetAttr, Timestamp};
+use futures_util::stream::{self, BoxStream};
+use futures_util::StreamExt;
+use std::ffi::OsStr;
+use std::fmt::Write;
+use tracing::{debug, error};
+
+/// A macro to log the result of an asynchronous method call in the context of 
FUSE operations.
+///
+/// This macro provides six variants for logging:
+/// 1. Without logging the reply (logs only the method status).
+/// 2. With default `Debug` formatting for the reply.
+/// 3. With a customizable formatting function for the reply.
+/// 4. With both Debug and custom formatting for the reply.
+/// 5. Special stream handling for `readdir` operations.
+/// 6. Special stream handling for `readdirplus` operations.
+///
+/// # Usage
+///
+/// ```ignore
+/// // No reply printing
+/// log_result!(method_call, "method_name", req);
+///
+/// // With default Debug formatting for the reply
+/// log_result!(method_call, "method_name", req, debug);
+///
+/// // With a custom formatting function for the reply
+/// log_result!(method_call, "method_name", req, custom_format_fn);
+///
+/// // With both Debug and custom formatting
+/// log_result!(method_call, "method_name", req, debug, custom_format_fn);
+///
+/// // Special handling for readdir stream
+/// log_result!(method_call, "readdir", req, stream);
+///
+/// // Special handling for readdirplus stream
+/// log_result!(method_call, "readdirplus", req, stream);
+/// ```
+///
+/// # Arguments
+///
+/// * `$method_call` - The asynchronous method call to execute and log.
+/// * `$method_name` - A string representing the name of the method for 
logging purposes.
+/// * `$req` - The incoming FUSE request associated with the method call.
+/// * Format Options (Optional):
+/// * No format option - Only logs method status
+/// * `debug` - Uses default Debug formatting for the reply
+/// * (`debug`, custom_format_fn) - Combines Debug output with custom 
formatted output
+/// * `stream` - Special handling for directory streams (only for 
"readdir"/"readdirplus")
+macro_rules! log_result {
+// No reply printing
+($method_call:expr, $method_name:expr, $req:ident) => {
+match $method_call.await {
+Ok(reply) => {
+debug!($req.unique, "{} completed", 
$method_name.to_uppercase());
+Ok(reply)
+}
+Err(e) => {
+error!($req.unique, ?e, "{} failed", 
$method_name.to_uppercase());
+Err(e)
+}
+}
+};
+
+// Default Debug formatting
+($method_call:expr, $method_name:expr, $req:ident, debug) => {
+match $method_call.await {
+Ok(reply) => {
+debug!(
+$req.unique,
+?reply,
+"{} completed",
+$method_name.to_uppercase()
+);
+Ok(reply)
+}
+Err(e) => {
+error!($req.unique, ?e, "{} failed", 
$method_name.to_uppercase());
+Err(e)
+}
+}
+};
+
+// Format stream for readdir
+($method_call:expr, "readdir", $req:ident, stream) => {{
+match $method_call.await {
+Ok(mut reply_dir) => {
+let mut entries = Vec::new();
+
+while let Some(entry_result) = reply_dir.entries.next().await {
+match entry_result {
+Ok(entry) => {
+

Re: [PR] [#5873] feat(gvfs-fuse): add debug log for FuseApiHandle [gravitino]

2025-02-26 Thread via GitHub


diqiu50 commented on code in PR #5905:
URL: https://github.com/apache/gravitino/pull/5905#discussion_r1972731829


##
clients/filesystem-fuse/src/fuse_api_handle_debug.rs:
##
@@ -0,0 +1,871 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+use crate::config::AppConfig;
+use crate::filesystem::{FileSystemContext, RawFileSystem};
+use crate::fuse_api_handle::FuseApiHandle;
+use chrono::DateTime;
+use fuse3::path::prelude::{ReplyData, ReplyOpen, ReplyStatFs, ReplyWrite};
+use fuse3::path::Request;
+use fuse3::raw::prelude::{
+FileAttr, ReplyAttr, ReplyCreated, ReplyDirectory, ReplyDirectoryPlus, 
ReplyEntry, ReplyInit,
+};
+use fuse3::raw::reply::{DirectoryEntry, DirectoryEntryPlus};
+use fuse3::raw::Filesystem;
+use fuse3::{Inode, SetAttr, Timestamp};
+use futures_util::stream::{self, BoxStream};
+use futures_util::StreamExt;
+use std::ffi::OsStr;
+use std::fmt::Write;
+use tracing::{debug, error};
+
+/// A macro to log the result of an asynchronous method call in the context of 
FUSE operations.
+///
+/// This macro provides six variants for logging:
+/// 1. Without logging the reply (logs only the method status).
+/// 2. With default `Debug` formatting for the reply.
+/// 3. With a customizable formatting function for the reply.
+/// 4. With both Debug and custom formatting for the reply.
+/// 5. Special stream handling for `readdir` operations.
+/// 6. Special stream handling for `readdirplus` operations.
+///
+/// # Usage
+///
+/// ```ignore
+/// // No reply printing
+/// log_result!(method_call, "method_name", req);
+///
+/// // With default Debug formatting for the reply
+/// log_result!(method_call, "method_name", req, debug);
+///
+/// // With a custom formatting function for the reply
+/// log_result!(method_call, "method_name", req, custom_format_fn);
+///
+/// // With both Debug and custom formatting
+/// log_result!(method_call, "method_name", req, debug, custom_format_fn);
+///
+/// // Special handling for readdir stream
+/// log_result!(method_call, "readdir", req, stream);
+///
+/// // Special handling for readdirplus stream
+/// log_result!(method_call, "readdirplus", req, stream);
+/// ```
+///
+/// # Arguments
+///
+/// * `$method_call` - The asynchronous method call to execute and log.
+/// * `$method_name` - A string representing the name of the method for 
logging purposes.
+/// * `$req` - The incoming FUSE request associated with the method call.
+/// * Format Options (Optional):
+/// * No format option - Only logs method status
+/// * `debug` - Uses default Debug formatting for the reply
+/// * (`debug`, custom_format_fn) - Combines Debug output with custom 
formatted output
+/// * `stream` - Special handling for directory streams (only for 
"readdir"/"readdirplus")
+macro_rules! log_result {
+// No reply printing
+($method_call:expr, $method_name:expr, $req:ident) => {
+match $method_call.await {
+Ok(reply) => {
+debug!($req.unique, "{} completed", 
$method_name.to_uppercase());
+Ok(reply)
+}
+Err(e) => {
+error!($req.unique, ?e, "{} failed", 
$method_name.to_uppercase());
+Err(e)
+}
+}
+};
+
+// Default Debug formatting
+($method_call:expr, $method_name:expr, $req:ident, debug) => {
+match $method_call.await {
+Ok(reply) => {
+debug!(
+$req.unique,
+?reply,
+"{} completed",
+$method_name.to_uppercase()
+);
+Ok(reply)
+}
+Err(e) => {
+error!($req.unique, ?e, "{} failed", 
$method_name.to_uppercase());
+Err(e)
+}
+}
+};
+
+// Format stream for readdir
+($method_call:expr, "readdir", $req:ident, stream) => {{
+match $method_call.await {
+Ok(mut reply_dir) => {
+let mut entries = Vec::new();
+
+while let Some(entry_result) = reply_dir.entries.next().await {
+match entry_result {
+Ok(entry) => {
+

Re: [PR] [#5873] feat(gvfs-fuse): add debug log for FuseApiHandle [gravitino]

2025-02-26 Thread via GitHub


diqiu50 commented on code in PR #5905:
URL: https://github.com/apache/gravitino/pull/5905#discussion_r1972729228


##
clients/filesystem-fuse/src/fuse_api_handle_debug.rs:
##
@@ -0,0 +1,871 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+use crate::config::AppConfig;
+use crate::filesystem::{FileSystemContext, RawFileSystem};
+use crate::fuse_api_handle::FuseApiHandle;
+use chrono::DateTime;
+use fuse3::path::prelude::{ReplyData, ReplyOpen, ReplyStatFs, ReplyWrite};
+use fuse3::path::Request;
+use fuse3::raw::prelude::{
+FileAttr, ReplyAttr, ReplyCreated, ReplyDirectory, ReplyDirectoryPlus, 
ReplyEntry, ReplyInit,
+};
+use fuse3::raw::reply::{DirectoryEntry, DirectoryEntryPlus};
+use fuse3::raw::Filesystem;
+use fuse3::{Inode, SetAttr, Timestamp};
+use futures_util::stream::{self, BoxStream};
+use futures_util::StreamExt;
+use std::ffi::OsStr;
+use std::fmt::Write;
+use tracing::{debug, error};
+
+/// A macro to log the result of an asynchronous method call in the context of 
FUSE operations.
+///
+/// This macro provides six variants for logging:
+/// 1. Without logging the reply (logs only the method status).
+/// 2. With default `Debug` formatting for the reply.
+/// 3. With a customizable formatting function for the reply.
+/// 4. With both Debug and custom formatting for the reply.
+/// 5. Special stream handling for `readdir` operations.
+/// 6. Special stream handling for `readdirplus` operations.
+///
+/// # Usage
+///
+/// ```ignore
+/// // No reply printing
+/// log_result!(method_call, "method_name", req);
+///
+/// // With default Debug formatting for the reply
+/// log_result!(method_call, "method_name", req, debug);

Review Comment:
   These macro's names it not clear to understand.
   What do you think of these:
   ```
   log_result → log_status
   log_result_debug → log_value
   log_result_custom → log_value_custom
   log_result_readdir → log_readdir
   ```



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]



Re: [PR] [#5873] feat(gvfs-fuse): add debug log for FuseApiHandle [gravitino]

2025-02-23 Thread via GitHub


unknowntpo commented on code in PR #5905:
URL: https://github.com/apache/gravitino/pull/5905#discussion_r1967001625


##
clients/filesystem-fuse/src/fuse_api_handle_debug.rs:
##
@@ -0,0 +1,871 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+use crate::config::AppConfig;
+use crate::filesystem::{FileSystemContext, RawFileSystem};
+use crate::fuse_api_handle::FuseApiHandle;
+use chrono::DateTime;
+use fuse3::path::prelude::{ReplyData, ReplyOpen, ReplyStatFs, ReplyWrite};
+use fuse3::path::Request;
+use fuse3::raw::prelude::{
+FileAttr, ReplyAttr, ReplyCreated, ReplyDirectory, ReplyDirectoryPlus, 
ReplyEntry, ReplyInit,
+};
+use fuse3::raw::reply::{DirectoryEntry, DirectoryEntryPlus};
+use fuse3::raw::Filesystem;
+use fuse3::{Inode, SetAttr, Timestamp};
+use futures_util::stream::{self, BoxStream};
+use futures_util::StreamExt;
+use std::ffi::OsStr;
+use std::fmt::Write;
+use tracing::{debug, error};
+
+/// A macro to log the result of an asynchronous method call in the context of 
FUSE operations.
+///
+/// This macro provides six variants for logging:
+/// 1. Without logging the reply (logs only the method status).
+/// 2. With default `Debug` formatting for the reply.
+/// 3. With a customizable formatting function for the reply.
+/// 4. With both Debug and custom formatting for the reply.
+/// 5. Special stream handling for `readdir` operations.
+/// 6. Special stream handling for `readdirplus` operations.
+///
+/// # Usage
+///
+/// ```ignore
+/// // No reply printing
+/// log_result!(method_call, "method_name", req);
+///
+/// // With default Debug formatting for the reply
+/// log_result!(method_call, "method_name", req, debug);
+///
+/// // With a custom formatting function for the reply
+/// log_result!(method_call, "method_name", req, custom_format_fn);
+///
+/// // With both Debug and custom formatting
+/// log_result!(method_call, "method_name", req, debug, custom_format_fn);
+///
+/// // Special handling for readdir stream
+/// log_result!(method_call, "readdir", req, stream);
+///
+/// // Special handling for readdirplus stream
+/// log_result!(method_call, "readdirplus", req, stream);
+/// ```
+///
+/// # Arguments
+///
+/// * `$method_call` - The asynchronous method call to execute and log.
+/// * `$method_name` - A string representing the name of the method for 
logging purposes.
+/// * `$req` - The incoming FUSE request associated with the method call.
+/// * Format Options (Optional):
+/// * No format option - Only logs method status
+/// * `debug` - Uses default Debug formatting for the reply
+/// * (`debug`, custom_format_fn) - Combines Debug output with custom 
formatted output
+/// * `stream` - Special handling for directory streams (only for 
"readdir"/"readdirplus")
+macro_rules! log_result {
+// No reply printing
+($method_call:expr, $method_name:expr, $req:ident) => {
+match $method_call.await {
+Ok(reply) => {
+debug!($req.unique, "{} completed", 
$method_name.to_uppercase());
+Ok(reply)
+}
+Err(e) => {
+error!($req.unique, ?e, "{} failed", 
$method_name.to_uppercase());
+Err(e)
+}
+}
+};
+
+// Default Debug formatting
+($method_call:expr, $method_name:expr, $req:ident, debug) => {
+match $method_call.await {
+Ok(reply) => {
+debug!(
+$req.unique,
+?reply,
+"{} completed",
+$method_name.to_uppercase()
+);
+Ok(reply)
+}
+Err(e) => {
+error!($req.unique, ?e, "{} failed", 
$method_name.to_uppercase());
+Err(e)
+}
+}
+};
+
+// Format stream for readdir
+($method_call:expr, "readdir", $req:ident, stream) => {{
+match $method_call.await {
+Ok(mut reply_dir) => {
+let mut entries = Vec::new();
+
+while let Some(entry_result) = reply_dir.entries.next().await {
+match entry_result {
+Ok(entry) => {
+ 

Re: [PR] [#5873] feat(gvfs-fuse): add debug log for FuseApiHandle [gravitino]

2025-02-23 Thread via GitHub


unknowntpo commented on PR #5905:
URL: https://github.com/apache/gravitino/pull/5905#issuecomment-2677353086

   @diqiu50 Done, please take a look.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]



Re: [PR] [#5873] feat(gvfs-fuse): add debug log for FuseApiHandle [gravitino]

2025-02-23 Thread via GitHub


unknowntpo commented on PR #5905:
URL: https://github.com/apache/gravitino/pull/5905#issuecomment-2677351314

   > We don’t need to enable logging for all crates, as that might result in an 
overwhelming amount of logs. Typically, logs from other crates should be 
disabled by default. If you want to enable logs for other modules, it’s best to 
do so through RUST_LOG or a configuration file. Our -d parameter is intended to 
control debug logs for our specific modules, which should be more effective for 
troubleshooting.
   
   I set `-d 2` to be the same as `-d 1` for now, and when 
`PathFileSystemDebugLog` is ready, we can add it. 


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]



Re: [PR] [#5873] feat(gvfs-fuse): add debug log for FuseApiHandle [gravitino]

2025-02-23 Thread via GitHub


unknowntpo commented on code in PR #5905:
URL: https://github.com/apache/gravitino/pull/5905#discussion_r1966976521


##
clients/filesystem-fuse/src/fuse_api_handle_debug.rs:
##
@@ -0,0 +1,871 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+use crate::config::AppConfig;
+use crate::filesystem::{FileSystemContext, RawFileSystem};
+use crate::fuse_api_handle::FuseApiHandle;
+use chrono::DateTime;
+use fuse3::path::prelude::{ReplyData, ReplyOpen, ReplyStatFs, ReplyWrite};
+use fuse3::path::Request;
+use fuse3::raw::prelude::{
+FileAttr, ReplyAttr, ReplyCreated, ReplyDirectory, ReplyDirectoryPlus, 
ReplyEntry, ReplyInit,
+};
+use fuse3::raw::reply::{DirectoryEntry, DirectoryEntryPlus};
+use fuse3::raw::Filesystem;
+use fuse3::{Inode, SetAttr, Timestamp};
+use futures_util::stream::{self, BoxStream};
+use futures_util::StreamExt;
+use std::ffi::OsStr;
+use std::fmt::Write;
+use tracing::{debug, error};
+
+/// A macro to log the result of an asynchronous method call in the context of 
FUSE operations.
+///
+/// This macro provides six variants for logging:
+/// 1. Without logging the reply (logs only the method status).
+/// 2. With default `Debug` formatting for the reply.
+/// 3. With a customizable formatting function for the reply.
+/// 4. With both Debug and custom formatting for the reply.
+/// 5. Special stream handling for `readdir` operations.
+/// 6. Special stream handling for `readdirplus` operations.
+///
+/// # Usage
+///
+/// ```ignore
+/// // No reply printing
+/// log_result!(method_call, "method_name", req);
+///
+/// // With default Debug formatting for the reply
+/// log_result!(method_call, "method_name", req, debug);

Review Comment:
   Ok, I think we can use:
   
   - `log_result!` for logging result without printing reply, originally 
`log_result!(method_call, "method_name", req);`
   - `log_result_debug!` for logging result with default debug formatting, 
originally `log_result!(method_call, "method_name", req, debug);`
   - `log_result_custom! ` for logging result with custom formatting, 
originally `log_result!(method_call, "method_name", req, debug, 
custom_format_fn);`
   - `log_result_readdir!` for readdir, originally `log_result!(method_call, 
"readdir", req, stream);`
   - `log_result_readdirplus!` for readdirplus, originally 
`log_result!(method_call, "readdirplus", req, stream);`



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]



Re: [PR] [#5873] feat(gvfs-fuse): add debug log for FuseApiHandle [gravitino]

2025-02-23 Thread via GitHub


unknowntpo commented on code in PR #5905:
URL: https://github.com/apache/gravitino/pull/5905#discussion_r1966976521


##
clients/filesystem-fuse/src/fuse_api_handle_debug.rs:
##
@@ -0,0 +1,871 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+use crate::config::AppConfig;
+use crate::filesystem::{FileSystemContext, RawFileSystem};
+use crate::fuse_api_handle::FuseApiHandle;
+use chrono::DateTime;
+use fuse3::path::prelude::{ReplyData, ReplyOpen, ReplyStatFs, ReplyWrite};
+use fuse3::path::Request;
+use fuse3::raw::prelude::{
+FileAttr, ReplyAttr, ReplyCreated, ReplyDirectory, ReplyDirectoryPlus, 
ReplyEntry, ReplyInit,
+};
+use fuse3::raw::reply::{DirectoryEntry, DirectoryEntryPlus};
+use fuse3::raw::Filesystem;
+use fuse3::{Inode, SetAttr, Timestamp};
+use futures_util::stream::{self, BoxStream};
+use futures_util::StreamExt;
+use std::ffi::OsStr;
+use std::fmt::Write;
+use tracing::{debug, error};
+
+/// A macro to log the result of an asynchronous method call in the context of 
FUSE operations.
+///
+/// This macro provides six variants for logging:
+/// 1. Without logging the reply (logs only the method status).
+/// 2. With default `Debug` formatting for the reply.
+/// 3. With a customizable formatting function for the reply.
+/// 4. With both Debug and custom formatting for the reply.
+/// 5. Special stream handling for `readdir` operations.
+/// 6. Special stream handling for `readdirplus` operations.
+///
+/// # Usage
+///
+/// ```ignore
+/// // No reply printing
+/// log_result!(method_call, "method_name", req);
+///
+/// // With default Debug formatting for the reply
+/// log_result!(method_call, "method_name", req, debug);

Review Comment:
   Ok, I think we can use:
   
   - `log_result!` for logging result without printing reply, originally 
`log_result!(method_call, "method_name", req);`
   - `log_result_debug!` for logging result with default debug formatting, 
originally `log_result!(method_call, "method_name", req, debug);`
   - `log_result_debug_custom! ` for logging result with custom debug 
formatting, originally `log_result!(method_call, "method_name", req, debug, 
custom_format_fn);`
   - `log_result_readdir!` for readdir, originally `log_result!(method_call, 
"readdir", req, stream);`
   - `log_result_readdirplus!` for readdirplus, originally 
`log_result!(method_call, "readdirplus", req, stream);`



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]



Re: [PR] [#5873] feat(gvfs-fuse): add debug log for FuseApiHandle [gravitino]

2025-02-23 Thread via GitHub


unknowntpo commented on code in PR #5905:
URL: https://github.com/apache/gravitino/pull/5905#discussion_r1966976521


##
clients/filesystem-fuse/src/fuse_api_handle_debug.rs:
##
@@ -0,0 +1,871 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+use crate::config::AppConfig;
+use crate::filesystem::{FileSystemContext, RawFileSystem};
+use crate::fuse_api_handle::FuseApiHandle;
+use chrono::DateTime;
+use fuse3::path::prelude::{ReplyData, ReplyOpen, ReplyStatFs, ReplyWrite};
+use fuse3::path::Request;
+use fuse3::raw::prelude::{
+FileAttr, ReplyAttr, ReplyCreated, ReplyDirectory, ReplyDirectoryPlus, 
ReplyEntry, ReplyInit,
+};
+use fuse3::raw::reply::{DirectoryEntry, DirectoryEntryPlus};
+use fuse3::raw::Filesystem;
+use fuse3::{Inode, SetAttr, Timestamp};
+use futures_util::stream::{self, BoxStream};
+use futures_util::StreamExt;
+use std::ffi::OsStr;
+use std::fmt::Write;
+use tracing::{debug, error};
+
+/// A macro to log the result of an asynchronous method call in the context of 
FUSE operations.
+///
+/// This macro provides six variants for logging:
+/// 1. Without logging the reply (logs only the method status).
+/// 2. With default `Debug` formatting for the reply.
+/// 3. With a customizable formatting function for the reply.
+/// 4. With both Debug and custom formatting for the reply.
+/// 5. Special stream handling for `readdir` operations.
+/// 6. Special stream handling for `readdirplus` operations.
+///
+/// # Usage
+///
+/// ```ignore
+/// // No reply printing
+/// log_result!(method_call, "method_name", req);
+///
+/// // With default Debug formatting for the reply
+/// log_result!(method_call, "method_name", req, debug);

Review Comment:
   Ok, I think we can use:
   
   - `log_result!` for logging result without printing reply, originally 
`log_result!(method_call, "method_name", req);`
   - `log_result_debug!` for logging result with default debug formatting, 
originally `log_result!(method_call, "method_name", req, debug);`
   - `log_result_custom!` for  logging result with custom formatting, 
originally `log_result!(method_call, "method_name", req, custom_format_fn)`
   - `log_result_debug_custom! ` for logging result with custom debug 
formatting, originally `log_result!(method_call, "method_name", req, debug, 
custom_format_fn);`
   - `log_result_readdir!` for readdir, originally `log_result!(method_call, 
"readdir", req, stream);`
   - `log_result_readdirplus!` for readdirplus, originally 
`log_result!(method_call, "readdirplus", req, stream);`



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]



Re: [PR] [#5873] feat(gvfs-fuse): add debug log for FuseApiHandle [gravitino]

2025-02-20 Thread via GitHub


diqiu50 commented on code in PR #5905:
URL: https://github.com/apache/gravitino/pull/5905#discussion_r1964988320


##
clients/filesystem-fuse/src/fuse_api_handle_debug.rs:
##
@@ -0,0 +1,871 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+use crate::config::AppConfig;
+use crate::filesystem::{FileSystemContext, RawFileSystem};
+use crate::fuse_api_handle::FuseApiHandle;
+use chrono::DateTime;
+use fuse3::path::prelude::{ReplyData, ReplyOpen, ReplyStatFs, ReplyWrite};
+use fuse3::path::Request;
+use fuse3::raw::prelude::{
+FileAttr, ReplyAttr, ReplyCreated, ReplyDirectory, ReplyDirectoryPlus, 
ReplyEntry, ReplyInit,
+};
+use fuse3::raw::reply::{DirectoryEntry, DirectoryEntryPlus};
+use fuse3::raw::Filesystem;
+use fuse3::{Inode, SetAttr, Timestamp};
+use futures_util::stream::{self, BoxStream};
+use futures_util::StreamExt;
+use std::ffi::OsStr;
+use std::fmt::Write;
+use tracing::{debug, error};
+
+/// A macro to log the result of an asynchronous method call in the context of 
FUSE operations.
+///
+/// This macro provides six variants for logging:
+/// 1. Without logging the reply (logs only the method status).
+/// 2. With default `Debug` formatting for the reply.
+/// 3. With a customizable formatting function for the reply.
+/// 4. With both Debug and custom formatting for the reply.
+/// 5. Special stream handling for `readdir` operations.
+/// 6. Special stream handling for `readdirplus` operations.
+///
+/// # Usage
+///
+/// ```ignore
+/// // No reply printing
+/// log_result!(method_call, "method_name", req);
+///
+/// // With default Debug formatting for the reply
+/// log_result!(method_call, "method_name", req, debug);
+///
+/// // With a custom formatting function for the reply
+/// log_result!(method_call, "method_name", req, custom_format_fn);
+///
+/// // With both Debug and custom formatting
+/// log_result!(method_call, "method_name", req, debug, custom_format_fn);
+///
+/// // Special handling for readdir stream
+/// log_result!(method_call, "readdir", req, stream);
+///
+/// // Special handling for readdirplus stream
+/// log_result!(method_call, "readdirplus", req, stream);
+/// ```
+///
+/// # Arguments
+///
+/// * `$method_call` - The asynchronous method call to execute and log.
+/// * `$method_name` - A string representing the name of the method for 
logging purposes.
+/// * `$req` - The incoming FUSE request associated with the method call.
+/// * Format Options (Optional):
+/// * No format option - Only logs method status
+/// * `debug` - Uses default Debug formatting for the reply
+/// * (`debug`, custom_format_fn) - Combines Debug output with custom 
formatted output
+/// * `stream` - Special handling for directory streams (only for 
"readdir"/"readdirplus")
+macro_rules! log_result {
+// No reply printing
+($method_call:expr, $method_name:expr, $req:ident) => {
+match $method_call.await {
+Ok(reply) => {
+debug!($req.unique, "{} completed", 
$method_name.to_uppercase());
+Ok(reply)
+}
+Err(e) => {
+error!($req.unique, ?e, "{} failed", 
$method_name.to_uppercase());
+Err(e)
+}
+}
+};
+
+// Default Debug formatting
+($method_call:expr, $method_name:expr, $req:ident, debug) => {
+match $method_call.await {
+Ok(reply) => {
+debug!(
+$req.unique,
+?reply,
+"{} completed",
+$method_name.to_uppercase()
+);
+Ok(reply)
+}
+Err(e) => {
+error!($req.unique, ?e, "{} failed", 
$method_name.to_uppercase());
+Err(e)
+}
+}
+};
+
+// Format stream for readdir
+($method_call:expr, "readdir", $req:ident, stream) => {{
+match $method_call.await {
+Ok(mut reply_dir) => {
+let mut entries = Vec::new();
+
+while let Some(entry_result) = reply_dir.entries.next().await {
+match entry_result {
+Ok(entry) => {
+

Re: [PR] [#5873] feat(gvfs-fuse): add debug log for FuseApiHandle [gravitino]

2025-02-20 Thread via GitHub


diqiu50 commented on code in PR #5905:
URL: https://github.com/apache/gravitino/pull/5905#discussion_r1964983024


##
clients/filesystem-fuse/src/fuse_api_handle_debug.rs:
##
@@ -0,0 +1,871 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+use crate::config::AppConfig;
+use crate::filesystem::{FileSystemContext, RawFileSystem};
+use crate::fuse_api_handle::FuseApiHandle;
+use chrono::DateTime;
+use fuse3::path::prelude::{ReplyData, ReplyOpen, ReplyStatFs, ReplyWrite};
+use fuse3::path::Request;
+use fuse3::raw::prelude::{
+FileAttr, ReplyAttr, ReplyCreated, ReplyDirectory, ReplyDirectoryPlus, 
ReplyEntry, ReplyInit,
+};
+use fuse3::raw::reply::{DirectoryEntry, DirectoryEntryPlus};
+use fuse3::raw::Filesystem;
+use fuse3::{Inode, SetAttr, Timestamp};
+use futures_util::stream::{self, BoxStream};
+use futures_util::StreamExt;
+use std::ffi::OsStr;
+use std::fmt::Write;
+use tracing::{debug, error};
+
+/// A macro to log the result of an asynchronous method call in the context of 
FUSE operations.
+///
+/// This macro provides six variants for logging:
+/// 1. Without logging the reply (logs only the method status).
+/// 2. With default `Debug` formatting for the reply.
+/// 3. With a customizable formatting function for the reply.
+/// 4. With both Debug and custom formatting for the reply.
+/// 5. Special stream handling for `readdir` operations.
+/// 6. Special stream handling for `readdirplus` operations.
+///
+/// # Usage
+///
+/// ```ignore
+/// // No reply printing
+/// log_result!(method_call, "method_name", req);
+///
+/// // With default Debug formatting for the reply
+/// log_result!(method_call, "method_name", req, debug);

Review Comment:
   I think using distinct names here, rather than just “debug” in the 
parameters, makes it easier to understand and use.
   We can use different macro names to differentiate between the requirements 
for various print outputs.
   



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]



Re: [PR] [#5873] feat(gvfs-fuse): add debug log for FuseApiHandle [gravitino]

2025-02-20 Thread via GitHub


diqiu50 commented on code in PR #5905:
URL: https://github.com/apache/gravitino/pull/5905#discussion_r1964983024


##
clients/filesystem-fuse/src/fuse_api_handle_debug.rs:
##
@@ -0,0 +1,871 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+use crate::config::AppConfig;
+use crate::filesystem::{FileSystemContext, RawFileSystem};
+use crate::fuse_api_handle::FuseApiHandle;
+use chrono::DateTime;
+use fuse3::path::prelude::{ReplyData, ReplyOpen, ReplyStatFs, ReplyWrite};
+use fuse3::path::Request;
+use fuse3::raw::prelude::{
+FileAttr, ReplyAttr, ReplyCreated, ReplyDirectory, ReplyDirectoryPlus, 
ReplyEntry, ReplyInit,
+};
+use fuse3::raw::reply::{DirectoryEntry, DirectoryEntryPlus};
+use fuse3::raw::Filesystem;
+use fuse3::{Inode, SetAttr, Timestamp};
+use futures_util::stream::{self, BoxStream};
+use futures_util::StreamExt;
+use std::ffi::OsStr;
+use std::fmt::Write;
+use tracing::{debug, error};
+
+/// A macro to log the result of an asynchronous method call in the context of 
FUSE operations.
+///
+/// This macro provides six variants for logging:
+/// 1. Without logging the reply (logs only the method status).
+/// 2. With default `Debug` formatting for the reply.
+/// 3. With a customizable formatting function for the reply.
+/// 4. With both Debug and custom formatting for the reply.
+/// 5. Special stream handling for `readdir` operations.
+/// 6. Special stream handling for `readdirplus` operations.
+///
+/// # Usage
+///
+/// ```ignore
+/// // No reply printing
+/// log_result!(method_call, "method_name", req);
+///
+/// // With default Debug formatting for the reply
+/// log_result!(method_call, "method_name", req, debug);

Review Comment:
   I think using distinct names here, rather than just “debug” in the 
parameters, makes it easier to understand and use.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]



Re: [PR] [#5873] feat(gvfs-fuse): add debug log for FuseApiHandle [gravitino]

2025-02-20 Thread via GitHub


diqiu50 commented on PR #5905:
URL: https://github.com/apache/gravitino/pull/5905#issuecomment-2673201367

   > * nable max_level = IINFO for all crates and modules
   
   We don’t need to enable logging for all crates, as that might result in an 
overwhelming amount of logs. Typically, logs from other crates should be 
disabled. If you need to enable logs for other modules, it’s best to do so 
through RUST_LOG or a configuration file. Our -d parameter is intended to 
control debug logs for our specific modules, which should be more effective for 
troubleshooting.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]



Re: [PR] [#5873] feat(gvfs-fuse): add debug log for FuseApiHandle [gravitino]

2025-02-19 Thread via GitHub


unknowntpo commented on PR #5905:
URL: https://github.com/apache/gravitino/pull/5905#issuecomment-2670327051

   @diqiu50 Ok, now:
   
   - [x]  if no `RUST_LOG` and no `-d` flag, show logs at max level =`INFO`
   - [x]  if have `RUST_LOG` , then ignore `-d` flag
   - [x]  if no `RUST_LOG` , and have `-d 1` , then  enable `FuseAPIHandle`, 
`FuseAPIHandleDebug` logs and  `max_level = INFO` for all crates and modules
   - [x]  if no `RUST_LOG` , and have `-d 2` , then  enable `max_level = DEBUG` 
for all crates and modules (this can be changed in the future)
   
   refactor my markdown list 


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]



Re: [PR] [#5873] feat(gvfs-fuse): add debug log for FuseApiHandle [gravitino]

2025-02-17 Thread via GitHub


diqiu50 commented on PR #5905:
URL: https://github.com/apache/gravitino/pull/5905#issuecomment-2664761418

   My suggestion is without using the environment variable, we should print 
logs at the [info, warn, and error] levels. When `-d 1` is passed, we will 
enable the FuseDebug Log.  when `-d 2` is passed , we start the other debug 
modules.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]



Re: [PR] [#5873] feat(gvfs-fuse): add debug log for FuseApiHandle [gravitino]

2025-02-17 Thread via GitHub


diqiu50 commented on PR #5905:
URL: https://github.com/apache/gravitino/pull/5905#issuecomment-2664755437

   The current issue is that when you use -d to enable debug logs, logs from 
all modules are printed, making it too messy, which is not what we want. We are 
designing a strategy where environment variables have the highest priority. If 
the environment variable is set, the -d parameter will be ignored. If -d 1 is 
passed, it will enable logging (like fuse-debug log). In the future, I would 
like to add similar debug features that can be triggered with -d 2, such as 
PathFileSystemDebugLog.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]



Re: [PR] [#5873] feat(gvfs-fuse): add debug log for FuseApiHandle [gravitino]

2025-02-16 Thread via GitHub


unknowntpo commented on PR #5905:
URL: https://github.com/apache/gravitino/pull/5905#issuecomment-2662250119

   > I hope we can control it through parameters. The log level configuration 
can be initialized through passed parameters.
   
   Indeed, and I think we can use `-d` to set debug level:
   
   - no `-d`: only shows `ERROR`, `WARNING`, `INFO`
   - `-d 1`: shows `DEBUG`, and use `FuseAPIHandleDebug` to log input / output 
of method calls.
   - `-d 2`: shows `TRACING`
   
   Ref: https://docs.rs/tracing/latest/tracing/struct.Level.html#implementations


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]



Re: [PR] [#5873] feat(gvfs-fuse): add debug log for FuseApiHandle [gravitino]

2025-02-16 Thread via GitHub


diqiu50 commented on PR #5905:
URL: https://github.com/apache/gravitino/pull/5905#issuecomment-2661837772

   I hope we can control it through parameters.
   The log level configuration can be initialized through passed parameters.
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]



Re: [PR] [#5873] feat(gvfs-fuse): add debug log for FuseApiHandle [gravitino]

2025-02-15 Thread via GitHub


unknowntpo commented on PR #5905:
URL: https://github.com/apache/gravitino/pull/5905#issuecomment-2661152283

   > I want to show the logs after running the gvfs-fuse with command:
   > 
   > ```
   > ./target/debug/gvfs-fuse mount target/gvfs 
gvfs://fileset/test/c1/s1/fileset1 -c conf/gvfs_fuse.toml -f -d 1
   > ```
   > 
   > The result was not expected. can you work on that, and copy the logs on 
the comments?
   > 
   > You need to apply patch with your code, and add logic with "-d" parameter :
   > 
   > ```
   > diff --git a/clients/filesystem-fuse/conf/gvfs_fuse.toml 
b/clients/filesystem-fuse/conf/gvfs_fuse.toml
   > index 76db3c4af..f1d8b46a2 100644
   > --- a/clients/filesystem-fuse/conf/gvfs_fuse.toml
   > +++ b/clients/filesystem-fuse/conf/gvfs_fuse.toml
   > @@ -21,7 +21,7 @@ file_mask = 0o600
   >  dir_mask = 0o700
   >  fs_type = "memory"
   >  fuse_debug = true
   > -data_path = "target/gvfs-fuse"
   > +data_dir = "target/gvfs-fuse"
   > 
   >  [fuse.properties]
   > 
   > diff --git a/clients/filesystem-fuse/src/main.rs 
b/clients/filesystem-fuse/src/main.rs
   > index aef5d71d3..5551512d8 100644
   > --- a/clients/filesystem-fuse/src/main.rs
   > +++ b/clients/filesystem-fuse/src/main.rs
   > @@ -34,13 +34,10 @@ use tracing::{error, info};
   > 
   >  fn init_work_dirs(config: &AppConfig, mount_point: &str) -> 
io::Result<()> {
   >  let data_dir_name = Path::new(&config.fuse.data_dir).to_path_buf();
   > -let data_dir_name = data_dir_name.canonicalize()?;
   >  if !data_dir_name.exists() {
   > -Err(io::Error::new(
   > -io::ErrorKind::NotFound,
   > -format!("Data directory {} not found", &config.fuse.data_dir),
   > -))?
   > +create_dir(&data_dir_name)?
   >  };
   > +let data_dir_name = data_dir_name.canonicalize()?;
   > 
   >  let mount_point_name = data_dir_name.join(mount_point);
   >  if !mount_point_name.exists() {
   > ```
   
   Done.
   
   Now, run this command:
   
   ```
   RUST_LOG=gvfs_fuse::fuse_api_handle=debug ./target/debug/gvfs-fuse mount 
target/gvfs gvfs://fileset/test/c1/s1/fileset1 -c conf/gvfs_fuse.toml -f -d 1
   ```
   
   We can see:
   
   ```
   2025-02-15T23:51:07.634665Z DEBUG gvfs_fuse::fuse_api_handle_debug: INIT 
started req.unique=2 uid=501 gid=20 pid=42347
   2025-02-15T23:51:07.634792Z DEBUG gvfs_fuse::fuse_api_handle_debug: INIT 
completed req.unique=2 reply=ReplyInit { max_write: 16384 }
   2025-02-15T23:51:07.635103Z DEBUG gvfs_fuse::fuse_api_handle_debug: STATFS 
started req.unique=2 uid=501 gid=20 pid=42347 filename="/" file_id=1
   2025-02-15T23:51:07.635138Z DEBUG gvfs_fuse::fuse_api_handle_debug: STATFS 
completed req.unique=2 reply=ReplyStatFs { blocks: 100, bfree: 100, 
bavail: 100, files: 100, ffree: 100, bsize: 4096, namelen: 255, 
frsize: 4096 }
   2025-02-15T23:51:07.635760Z DEBUG gvfs_fuse::fuse_api_handle_debug: STATFS 
started req.unique=2 uid=0 gid=0 pid=134 filename="/" file_id=1
   2025-02-15T23:51:07.635788Z DEBUG gvfs_fuse::fuse_api_handle_debug: STATFS 
completed req.unique=2 reply=ReplyStatFs { blocks: 100, bfree: 100, 
bavail: 100, files: 100, ffree: 100, bsize: 4096, namelen: 255, 
frsize: 4096 }
   2025-02-15T23:51:07.635848Z DEBUG gvfs_fuse::fuse_api_handle_debug: STATFS 
started req.unique=3 uid=0 gid=0 pid=177 filename="/" file_id=1
   2025-02-15T23:51:07.639085Z DEBUG gvfs_fuse::fuse_api_handle_debug: STATFS 
completed req.unique=3 reply=ReplyStatFs { blocks: 100, bfree: 100, 
bavail: 100, files: 100, ffree: 100, bsize: 4096, namelen: 255, 
frsize: 4096 }
   2025-02-15T23:51:07.639332Z DEBUG gvfs_fuse::fuse_api_handle_debug: STATFS 
started req.unique=2 uid=0 gid=0 pid=177 filename="/" file_id=1
   2025-02-15T23:51:07.639355Z DEBUG gvfs_fuse::fuse_api_handle_debug: STATFS 
completed req.unique=2 reply=ReplyStatFs { blocks: 100, bfree: 100, 
bavail: 100, files: 100, ffree: 100, bsize: 4096, namelen: 255, 
frsize: 4096 }
   2025-02-15T23:51:07.642632Z DEBUG gvfs_fuse::fuse_api_handle_debug: GETATTR 
started req.unique=3 uid=501 gid=20 pid=181 filename="/" fh=None flags=0
   2025-02-15T23:51:07.646496Z DEBUG gvfs_fuse::fuse_api_handle_debug: GETATTR 
completed req.unique=3 reply="ttl: 1s, FileAttr: { ino: 1, size: 0, blocks: 0, 
atime: 2025-02-15 23:51:07.646405, mtime: 2025-02-15 23:51:07.646405, ctime: 
2025-02-15 23:51:07.646405, crtime: 2025-02-15 23:51:07.646405, kind: 
Directory, perm: 700, nlink: 1, uid: 501, gid: 20, rdev: 0, flags: 0, blksize: 
8192 }"
   2025-02-15T23:51:07.646597Z DEBUG gvfs_fuse::fuse_api_handle_debug: STATFS 
started req.unique=2 uid=0 gid=0 pid=177 filename="/" file_id=1
   2025-02-15T23:51:07.652205Z DEBUG gvfs_fuse::fuse_api_handle_debug: STATFS 
completed req.unique=2 reply=ReplyStatFs { blocks: 100, bfree: 100, 
bavail: 100, files: 100, ffree: 100, bsize: 4096, namelen: 255, 
frsize: 4096 }
   2025-02-15T23:51

Re: [PR] [#5873] feat(gvfs-fuse): add debug log for FuseApiHandle [gravitino]

2025-02-13 Thread via GitHub


diqiu50 commented on PR #5905:
URL: https://github.com/apache/gravitino/pull/5905#issuecomment-2658474034

   I want to show the logs after running the gvfs-fuse with command:
   ```
   ./target/debug/gvfs-fuse mount target/gvfs 
gvfs://fileset/test/c1/s1/fileset1 -c conf/gvfs_fuse.toml -f -d 1
   ```
   The result was not expected. can you work on that, and copy the logs on the 
comments?
   
   You need to apply patch with your code, and add logic with "-d" parameter :
   ```
   diff --git a/clients/filesystem-fuse/conf/gvfs_fuse.toml 
b/clients/filesystem-fuse/conf/gvfs_fuse.toml
   index 76db3c4af..f1d8b46a2 100644
   --- a/clients/filesystem-fuse/conf/gvfs_fuse.toml
   +++ b/clients/filesystem-fuse/conf/gvfs_fuse.toml
   @@ -21,7 +21,7 @@ file_mask = 0o600
dir_mask = 0o700
fs_type = "memory"
fuse_debug = true
   -data_path = "target/gvfs-fuse"
   +data_dir = "target/gvfs-fuse"
   
[fuse.properties]
   
   diff --git a/clients/filesystem-fuse/src/main.rs 
b/clients/filesystem-fuse/src/main.rs
   index aef5d71d3..5551512d8 100644
   --- a/clients/filesystem-fuse/src/main.rs
   +++ b/clients/filesystem-fuse/src/main.rs
   @@ -34,13 +34,10 @@ use tracing::{error, info};
   
fn init_work_dirs(config: &AppConfig, mount_point: &str) -> io::Result<()> {
let data_dir_name = Path::new(&config.fuse.data_dir).to_path_buf();
   -let data_dir_name = data_dir_name.canonicalize()?;
if !data_dir_name.exists() {
   -Err(io::Error::new(
   -io::ErrorKind::NotFound,
   -format!("Data directory {} not found", &config.fuse.data_dir),
   -))?
   +create_dir(&data_dir_name)?
};
   +let data_dir_name = data_dir_name.canonicalize()?;
   
let mount_point_name = data_dir_name.join(mount_point);
if !mount_point_name.exists() {
   ```
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]



Re: [PR] [#5873] feat(gvfs-fuse): add debug log for FuseApiHandle [gravitino]

2025-02-09 Thread via GitHub


unknowntpo commented on PR #5905:
URL: https://github.com/apache/gravitino/pull/5905#issuecomment-2646184462

   @diqiu50 Sorry I'm late, I've finished the modification, please take a look.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]



Re: [PR] [#5873] feat(gvfs-fuse): add debug log for FuseApiHandle [gravitino]

2025-02-09 Thread via GitHub


unknowntpo commented on code in PR #5905:
URL: https://github.com/apache/gravitino/pull/5905#discussion_r1948067099


##
clients/filesystem-fuse/src/fuse_api_handle_debug.rs:
##
@@ -0,0 +1,737 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+use crate::config::AppConfig;
+use crate::filesystem::{FileSystemContext, RawFileSystem};
+use crate::fuse_api_handle::FuseApiHandle;
+use chrono::DateTime;
+use fuse3::path::prelude::{ReplyData, ReplyOpen, ReplyStatFs, ReplyWrite};
+use fuse3::path::Request;
+use fuse3::raw::prelude::{
+FileAttr, ReplyAttr, ReplyCreated, ReplyDirectory, ReplyDirectoryPlus, 
ReplyEntry, ReplyInit,
+};
+use fuse3::raw::reply::{DirectoryEntry, DirectoryEntryPlus};
+use fuse3::raw::Filesystem;
+use fuse3::{Inode, SetAttr, Timestamp};
+use futures_util::stream::{BoxStream};
+use futures_util::{StreamExt};
+use std::ffi::{OsStr};
+use std::fmt::Write;
+use tracing::{debug, error};
+
+/// A macro to log the result of an asynchronous method call in the context of 
FUSE operations.
+///
+/// This macro provides three variants for logging:
+/// 1. Without logging the reply (logs only the method status).
+/// 2. With default `Debug` formatting for the reply.
+/// 3. With a customizable formatting function for the reply.
+///
+/// # Usage
+///
+/// ```ignore
+/// // No reply printing
+/// log_result!(method_call, "method_name", req);
+///
+/// // With default Debug formatting for the reply
+/// log_result!(method_call, "method_name", req, debug);
+///
+/// // With a custom formatting function for the reply
+/// log_result!(method_call, "method_name", req, custom_format_fn);
+/// ```
+///
+/// # Arguments
+///
+/// - `$method_call`: The asynchronous method call to execute and log.
+/// - `$method_name`: A string representing the name of the method for logging 
purposes.
+/// - `$req`: The incoming FUSE request associated with the method call.
+/// - `$format_reply_fn`: (Optional) A custom formatting function to describe 
the reply more specifically.
+macro_rules! log_result {
+   // No reply printing
+   ($method_call:expr, $method_name:expr, $req:ident) => {
+match $method_call.await {
+Ok(reply) => {
+debug!($req.unique, concat!($method_name, " completed"));
+Ok(reply)
+}
+Err(e) => {
+error!($req.unique, ?e, concat!($method_name, " failed"));
+Err(e)
+}
+}
+};
+
+// Default Debug formatting
+($method_call:expr, $method_name:expr, $req:ident, debug) => {
+match $method_call.await {
+Ok(reply) => {
+debug!($req.unique, ?reply, concat!($method_name, " 
completed"));
+Ok(reply)
+}
+Err(e) => {
+error!($req.unique, ?e, concat!($method_name, " failed"));
+Err(e)
+}
+}
+};
+
+// Format reply with custom formatting function
+($method_call:expr, $method_name:expr, $req:ident, $format_reply_fn:ident) 
=> {
+match $method_call.await {
+Ok(reply) => {
+debug!($req.unique, reply = %$format_reply_fn(&reply), 
concat!($method_name, " completed"));
+Ok(reply)
+}
+Err(e) => {
+error!($req.unique, ?e, concat!($method_name, " failed"));
+Err(e)
+}
+}
+};
+
+// Format stream with custom formatting function
+($method_call:expr, $method_name:expr, $req:ident, stream, 
$format_reply_fn:expr) => {{
+match $method_call.await {
+Ok(reply_dir) => {
+let mut stream = reply_dir.entries.peekable();
+let mut debug_output = String::new();
+while let Some(entry_result) = stream.peek().await {
+match entry_result {
+Ok(entry) => {
+debug_output.push_str(format!("Directory entry: 
{:?}\n", entry).as_str());
+}
+Err(e) => {
+debug_output.push_str(format!("Error reading 
directory entry: {:?}\n", e).as_str());
+   

Re: [PR] [#5873] feat(gvfs-fuse): add debug log for FuseApiHandle [gravitino]

2025-02-09 Thread via GitHub


unknowntpo commented on code in PR #5905:
URL: https://github.com/apache/gravitino/pull/5905#discussion_r1948066985


##
clients/filesystem-fuse/src/fuse_api_handle_debug.rs:
##
@@ -0,0 +1,584 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+use crate::config::AppConfig;
+use crate::filesystem::{FileSystemContext, RawFileSystem};
+use crate::fuse_api_handle::FuseApiHandle;
+use chrono::DateTime;
+use fuse3::path::prelude::{ReplyData, ReplyOpen, ReplyStatFs, ReplyWrite};
+use fuse3::path::Request;
+use fuse3::raw::prelude::{
+FileAttr, ReplyAttr, ReplyCreated, ReplyDirectory, ReplyDirectoryPlus, 
ReplyEntry, ReplyInit,
+};
+use fuse3::raw::reply::{DirectoryEntry, DirectoryEntryPlus};
+use fuse3::raw::Filesystem;
+use fuse3::{Inode, SetAttr, Timestamp};
+use futures_util::stream::BoxStream;
+use std::ffi::OsStr;
+use std::fmt::Write;
+use tracing::{debug, error};
+
+/// A macro to log the result of an asynchronous method call in the context of 
FUSE operations.
+///
+/// This macro provides three variants for logging:
+/// 1. Without logging the reply (logs only the method status).
+/// 2. With default `Debug` formatting for the reply.
+/// 3. With a customizable formatting function for the reply.
+///
+/// # Usage
+///
+/// ```ignore
+/// // No reply printing
+/// log_result!(method_call, "method_name", req);
+///
+/// // With default Debug formatting for the reply
+/// log_result!(method_call, "method_name", req, debug);
+///
+/// // With a custom formatting function for the reply
+/// log_result!(method_call, "method_name", req, custom_format_fn);
+/// ```
+///
+/// # Arguments
+///
+/// - `$method_call`: The asynchronous method call to execute and log.
+/// - `$method_name`: A string representing the name of the method for logging 
purposes.
+/// - `$req`: The incoming FUSE request associated with the method call.
+/// - `$format_reply_fn`: (Optional) A custom formatting function to describe 
the reply more specifically.
+macro_rules! log_result {
+   // No reply printing
+   ($method_call:expr, $method_name:expr, $req:ident) => {
+match $method_call.await {
+Ok(reply) => {
+debug!($req.unique, concat!($method_name, " completed"));
+Ok(reply)
+}
+Err(e) => {
+error!($req.unique, ?e, concat!($method_name, " failed"));
+Err(e)
+}
+}
+};
+
+// Default Debug formatting
+($method_call:expr, $method_name:expr, $req:ident, debug) => {
+match $method_call.await {
+Ok(reply) => {
+debug!($req.unique, ?reply, concat!($method_name, " 
completed"));
+Ok(reply)
+}
+Err(e) => {
+error!($req.unique, ?e, concat!($method_name, " failed"));
+Err(e)
+}
+}
+};
+
+// Format reply with custom format function
+($method_call:expr, $method_name:expr, $req:ident, $format_reply_fn:ident) 
=> {
+match $method_call.await {
+Ok(reply) => {
+debug!($req.unique, reply = %$format_reply_fn(&reply), 
concat!($method_name, " completed"));
+Ok(reply)
+}
+Err(e) => {
+error!($req.unique, ?e, concat!($method_name, " failed"));
+Err(e)
+}
+}
+};
+}
+
+/// Convert `ReplyAttr` to descriptive string.
+///
+/// Example: `ttl: 1s, FileAttr: { ino: 1, size: 0, blocks: 0, atime: 
"2025-01-16 02:42:52.600436", mtime: "2025-01-16 02:42:52.600436", ctime: 
"2025-01-16 02:42:52.600436", crtime: "2025-01-16 02:42:52.600436", kind: 
RegularFile, perm: 600, nlink: 1, uid: 501, gid: 20, rdev: 0, flags: 0, 
blksize: 8192 }`
+fn reply_attr_to_desc_str(reply_attr: &ReplyAttr) -> String {
+let mut output = String::new();
+
+write!(output, "ttl: {:?}, ", reply_attr.ttl).unwrap();
+write!(
+output,
+"FileAttr: {}",
+file_attr_to_desc_str(&reply_attr.attr)
+)
+.unwrap();
+

Review Comment:
   Done.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use t

Re: [PR] [#5873] feat(gvfs-fuse): add debug log for FuseApiHandle [gravitino]

2025-02-09 Thread via GitHub


unknowntpo commented on code in PR #5905:
URL: https://github.com/apache/gravitino/pull/5905#discussion_r1948066319


##
clients/filesystem-fuse/src/fuse_api_handle_debug.rs:
##
@@ -0,0 +1,584 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+use crate::config::AppConfig;
+use crate::filesystem::{FileSystemContext, RawFileSystem};
+use crate::fuse_api_handle::FuseApiHandle;
+use chrono::DateTime;
+use fuse3::path::prelude::{ReplyData, ReplyOpen, ReplyStatFs, ReplyWrite};
+use fuse3::path::Request;
+use fuse3::raw::prelude::{
+FileAttr, ReplyAttr, ReplyCreated, ReplyDirectory, ReplyDirectoryPlus, 
ReplyEntry, ReplyInit,
+};
+use fuse3::raw::reply::{DirectoryEntry, DirectoryEntryPlus};
+use fuse3::raw::Filesystem;
+use fuse3::{Inode, SetAttr, Timestamp};
+use futures_util::stream::BoxStream;
+use std::ffi::OsStr;
+use std::fmt::Write;
+use tracing::{debug, error};
+
+/// A macro to log the result of an asynchronous method call in the context of 
FUSE operations.
+///
+/// This macro provides three variants for logging:
+/// 1. Without logging the reply (logs only the method status).
+/// 2. With default `Debug` formatting for the reply.
+/// 3. With a customizable formatting function for the reply.
+///
+/// # Usage
+///
+/// ```ignore
+/// // No reply printing
+/// log_result!(method_call, "method_name", req);
+///
+/// // With default Debug formatting for the reply
+/// log_result!(method_call, "method_name", req, debug);
+///
+/// // With a custom formatting function for the reply
+/// log_result!(method_call, "method_name", req, custom_format_fn);
+/// ```
+///
+/// # Arguments
+///
+/// - `$method_call`: The asynchronous method call to execute and log.
+/// - `$method_name`: A string representing the name of the method for logging 
purposes.
+/// - `$req`: The incoming FUSE request associated with the method call.
+/// - `$format_reply_fn`: (Optional) A custom formatting function to describe 
the reply more specifically.
+macro_rules! log_result {
+   // No reply printing
+   ($method_call:expr, $method_name:expr, $req:ident) => {
+match $method_call.await {
+Ok(reply) => {
+debug!($req.unique, concat!($method_name, " completed"));
+Ok(reply)
+}
+Err(e) => {
+error!($req.unique, ?e, concat!($method_name, " failed"));
+Err(e)
+}
+}
+};
+
+// Default Debug formatting
+($method_call:expr, $method_name:expr, $req:ident, debug) => {
+match $method_call.await {
+Ok(reply) => {
+debug!($req.unique, ?reply, concat!($method_name, " 
completed"));
+Ok(reply)
+}
+Err(e) => {
+error!($req.unique, ?e, concat!($method_name, " failed"));
+Err(e)
+}
+}
+};
+
+// Format reply with custom format function
+($method_call:expr, $method_name:expr, $req:ident, $format_reply_fn:ident) 
=> {
+match $method_call.await {
+Ok(reply) => {
+debug!($req.unique, reply = %$format_reply_fn(&reply), 
concat!($method_name, " completed"));
+Ok(reply)
+}
+Err(e) => {
+error!($req.unique, ?e, concat!($method_name, " failed"));
+Err(e)
+}
+}
+};
+}
+
+/// Convert `ReplyAttr` to descriptive string.
+///
+/// Example: `ttl: 1s, FileAttr: { ino: 1, size: 0, blocks: 0, atime: 
"2025-01-16 02:42:52.600436", mtime: "2025-01-16 02:42:52.600436", ctime: 
"2025-01-16 02:42:52.600436", crtime: "2025-01-16 02:42:52.600436", kind: 
RegularFile, perm: 600, nlink: 1, uid: 501, gid: 20, rdev: 0, flags: 0, 
blksize: 8192 }`

Review Comment:
   I format example like this for readability.
   
   ```
   /// Convert `ReplyAttr` to descriptive string.
   ///
   /// Example (pretty-printed for readability):
   /// ```text
   /// ttl: 1s,
   /// FileAttr: {
   /// ino: 1,
   /// size: 0,
   /// blocks: 0,
   /// atime: 2025-01-16 02:42:52.600436,
   /// mtime: 2025-01-16 02:42:52.600436,
   /// ctime: 2025-01-16 02:42:52.600436,
   ///   

Re: [PR] [#5873] feat(gvfs-fuse): add debug log for FuseApiHandle [gravitino]

2025-02-09 Thread via GitHub


unknowntpo commented on code in PR #5905:
URL: https://github.com/apache/gravitino/pull/5905#discussion_r1948066128


##
clients/filesystem-fuse/conf/gvfs_fuse.toml:
##
@@ -20,6 +20,7 @@
 file_mask = 0o600
 dir_mask = 0o700
 fs_type = "memory"
+fuse_debug=true
 

Review Comment:
   Done.



##
clients/filesystem-fuse/src/config.rs:
##
@@ -265,6 +265,8 @@ pub struct FuseConfig {
 #[serde(default)]
 pub fs_type: String,
 #[serde(default)]
+pub fuse_debug: bool,
+#[serde(default)]

Review Comment:
   Done.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]



Re: [PR] [#5873] feat(gvfs-fuse): add debug log for FuseApiHandle [gravitino]

2025-02-09 Thread via GitHub


unknowntpo commented on code in PR #5905:
URL: https://github.com/apache/gravitino/pull/5905#discussion_r1948066172


##
clients/filesystem-fuse/src/fuse_api_handle.rs:
##
@@ -53,7 +53,7 @@ impl FuseApiHandle {
 }
 }
 
-async fn get_modified_file_stat(
+pub async fn get_modified_file_stat(
 &self,

Review Comment:
   Done.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]



Re: [PR] [#5873] feat(gvfs-fuse): add debug log for FuseApiHandle [gravitino]

2025-02-09 Thread via GitHub


unknowntpo commented on code in PR #5905:
URL: https://github.com/apache/gravitino/pull/5905#discussion_r1948066100


##
clients/filesystem-fuse/Cargo.toml:
##
@@ -46,6 +47,7 @@ opendal = { version = "0.46.0", features = ["services-s3"] }
 reqwest = { version = "0.12.9", features = ["json"] }
 serde = { version = "1.0.216", features = ["derive"] }
 tokio = { version = "1.38.0", features = ["full"] }
+tracing = "0.1.41"

Review Comment:
   Done.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]



Re: [PR] [#5873] feat(gvfs-fuse): add debug log for FuseApiHandle [gravitino]

2025-01-24 Thread via GitHub


diqiu50 commented on code in PR #5905:
URL: https://github.com/apache/gravitino/pull/5905#discussion_r1928362286


##
clients/filesystem-fuse/src/fuse_api_handle_debug.rs:
##
@@ -0,0 +1,737 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+use crate::config::AppConfig;
+use crate::filesystem::{FileSystemContext, RawFileSystem};
+use crate::fuse_api_handle::FuseApiHandle;
+use chrono::DateTime;
+use fuse3::path::prelude::{ReplyData, ReplyOpen, ReplyStatFs, ReplyWrite};
+use fuse3::path::Request;
+use fuse3::raw::prelude::{
+FileAttr, ReplyAttr, ReplyCreated, ReplyDirectory, ReplyDirectoryPlus, 
ReplyEntry, ReplyInit,
+};
+use fuse3::raw::reply::{DirectoryEntry, DirectoryEntryPlus};
+use fuse3::raw::Filesystem;
+use fuse3::{Inode, SetAttr, Timestamp};
+use futures_util::stream::{BoxStream};
+use futures_util::{StreamExt};
+use std::ffi::{OsStr};
+use std::fmt::Write;
+use tracing::{debug, error};
+
+/// A macro to log the result of an asynchronous method call in the context of 
FUSE operations.
+///
+/// This macro provides three variants for logging:
+/// 1. Without logging the reply (logs only the method status).
+/// 2. With default `Debug` formatting for the reply.
+/// 3. With a customizable formatting function for the reply.
+///
+/// # Usage
+///
+/// ```ignore
+/// // No reply printing
+/// log_result!(method_call, "method_name", req);
+///
+/// // With default Debug formatting for the reply
+/// log_result!(method_call, "method_name", req, debug);
+///
+/// // With a custom formatting function for the reply
+/// log_result!(method_call, "method_name", req, custom_format_fn);
+/// ```
+///
+/// # Arguments
+///
+/// - `$method_call`: The asynchronous method call to execute and log.
+/// - `$method_name`: A string representing the name of the method for logging 
purposes.
+/// - `$req`: The incoming FUSE request associated with the method call.
+/// - `$format_reply_fn`: (Optional) A custom formatting function to describe 
the reply more specifically.
+macro_rules! log_result {
+   // No reply printing
+   ($method_call:expr, $method_name:expr, $req:ident) => {
+match $method_call.await {
+Ok(reply) => {
+debug!($req.unique, concat!($method_name, " completed"));
+Ok(reply)
+}
+Err(e) => {
+error!($req.unique, ?e, concat!($method_name, " failed"));
+Err(e)
+}
+}
+};
+
+// Default Debug formatting
+($method_call:expr, $method_name:expr, $req:ident, debug) => {
+match $method_call.await {
+Ok(reply) => {
+debug!($req.unique, ?reply, concat!($method_name, " 
completed"));
+Ok(reply)
+}
+Err(e) => {
+error!($req.unique, ?e, concat!($method_name, " failed"));
+Err(e)
+}
+}
+};
+
+// Format reply with custom formatting function
+($method_call:expr, $method_name:expr, $req:ident, $format_reply_fn:ident) 
=> {
+match $method_call.await {
+Ok(reply) => {
+debug!($req.unique, reply = %$format_reply_fn(&reply), 
concat!($method_name, " completed"));
+Ok(reply)
+}
+Err(e) => {
+error!($req.unique, ?e, concat!($method_name, " failed"));
+Err(e)
+}
+}
+};
+
+// Format stream with custom formatting function
+($method_call:expr, $method_name:expr, $req:ident, stream, 
$format_reply_fn:expr) => {{
+match $method_call.await {
+Ok(reply_dir) => {
+let mut stream = reply_dir.entries.peekable();
+let mut debug_output = String::new();
+while let Some(entry_result) = stream.peek().await {
+match entry_result {
+Ok(entry) => {
+debug_output.push_str(format!("Directory entry: 
{:?}\n", entry).as_str());
+}
+Err(e) => {
+debug_output.push_str(format!("Error reading 
directory entry: {:?}\n", e).as_str());
+  

Re: [PR] [#5873] feat(gvfs-fuse): add debug log for FuseApiHandle [gravitino]

2025-01-24 Thread via GitHub


diqiu50 commented on code in PR #5905:
URL: https://github.com/apache/gravitino/pull/5905#discussion_r1928336748


##
clients/filesystem-fuse/src/fuse_api_handle_debug.rs:
##
@@ -0,0 +1,737 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+use crate::config::AppConfig;
+use crate::filesystem::{FileSystemContext, RawFileSystem};
+use crate::fuse_api_handle::FuseApiHandle;
+use chrono::DateTime;
+use fuse3::path::prelude::{ReplyData, ReplyOpen, ReplyStatFs, ReplyWrite};
+use fuse3::path::Request;
+use fuse3::raw::prelude::{
+FileAttr, ReplyAttr, ReplyCreated, ReplyDirectory, ReplyDirectoryPlus, 
ReplyEntry, ReplyInit,
+};
+use fuse3::raw::reply::{DirectoryEntry, DirectoryEntryPlus};
+use fuse3::raw::Filesystem;
+use fuse3::{Inode, SetAttr, Timestamp};
+use futures_util::stream::{BoxStream};
+use futures_util::{StreamExt};
+use std::ffi::{OsStr};
+use std::fmt::Write;
+use tracing::{debug, error};
+
+/// A macro to log the result of an asynchronous method call in the context of 
FUSE operations.
+///
+/// This macro provides three variants for logging:
+/// 1. Without logging the reply (logs only the method status).
+/// 2. With default `Debug` formatting for the reply.
+/// 3. With a customizable formatting function for the reply.
+///
+/// # Usage
+///
+/// ```ignore
+/// // No reply printing
+/// log_result!(method_call, "method_name", req);
+///
+/// // With default Debug formatting for the reply
+/// log_result!(method_call, "method_name", req, debug);
+///
+/// // With a custom formatting function for the reply
+/// log_result!(method_call, "method_name", req, custom_format_fn);
+/// ```
+///
+/// # Arguments
+///
+/// - `$method_call`: The asynchronous method call to execute and log.
+/// - `$method_name`: A string representing the name of the method for logging 
purposes.
+/// - `$req`: The incoming FUSE request associated with the method call.
+/// - `$format_reply_fn`: (Optional) A custom formatting function to describe 
the reply more specifically.
+macro_rules! log_result {
+   // No reply printing
+   ($method_call:expr, $method_name:expr, $req:ident) => {
+match $method_call.await {
+Ok(reply) => {
+debug!($req.unique, concat!($method_name, " completed"));
+Ok(reply)
+}
+Err(e) => {
+error!($req.unique, ?e, concat!($method_name, " failed"));
+Err(e)
+}
+}
+};
+
+// Default Debug formatting
+($method_call:expr, $method_name:expr, $req:ident, debug) => {
+match $method_call.await {
+Ok(reply) => {
+debug!($req.unique, ?reply, concat!($method_name, " 
completed"));
+Ok(reply)
+}
+Err(e) => {
+error!($req.unique, ?e, concat!($method_name, " failed"));
+Err(e)
+}
+}
+};
+
+// Format reply with custom formatting function
+($method_call:expr, $method_name:expr, $req:ident, $format_reply_fn:ident) 
=> {
+match $method_call.await {
+Ok(reply) => {
+debug!($req.unique, reply = %$format_reply_fn(&reply), 
concat!($method_name, " completed"));
+Ok(reply)
+}
+Err(e) => {
+error!($req.unique, ?e, concat!($method_name, " failed"));
+Err(e)
+}
+}
+};
+
+// Format stream with custom formatting function
+($method_call:expr, $method_name:expr, $req:ident, stream, 
$format_reply_fn:expr) => {{
+match $method_call.await {
+Ok(reply_dir) => {
+let mut stream = reply_dir.entries.peekable();
+let mut debug_output = String::new();
+while let Some(entry_result) = stream.peek().await {
+match entry_result {
+Ok(entry) => {
+debug_output.push_str(format!("Directory entry: 
{:?}\n", entry).as_str());
+}
+Err(e) => {
+debug_output.push_str(format!("Error reading 
directory entry: {:?}\n", e).as_str());
+  

Re: [PR] [#5873] feat(gvfs-fuse): add debug log for FuseApiHandle [gravitino]

2025-01-24 Thread via GitHub


diqiu50 commented on code in PR #5905:
URL: https://github.com/apache/gravitino/pull/5905#discussion_r1928336748


##
clients/filesystem-fuse/src/fuse_api_handle_debug.rs:
##
@@ -0,0 +1,737 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+use crate::config::AppConfig;
+use crate::filesystem::{FileSystemContext, RawFileSystem};
+use crate::fuse_api_handle::FuseApiHandle;
+use chrono::DateTime;
+use fuse3::path::prelude::{ReplyData, ReplyOpen, ReplyStatFs, ReplyWrite};
+use fuse3::path::Request;
+use fuse3::raw::prelude::{
+FileAttr, ReplyAttr, ReplyCreated, ReplyDirectory, ReplyDirectoryPlus, 
ReplyEntry, ReplyInit,
+};
+use fuse3::raw::reply::{DirectoryEntry, DirectoryEntryPlus};
+use fuse3::raw::Filesystem;
+use fuse3::{Inode, SetAttr, Timestamp};
+use futures_util::stream::{BoxStream};
+use futures_util::{StreamExt};
+use std::ffi::{OsStr};
+use std::fmt::Write;
+use tracing::{debug, error};
+
+/// A macro to log the result of an asynchronous method call in the context of 
FUSE operations.
+///
+/// This macro provides three variants for logging:
+/// 1. Without logging the reply (logs only the method status).
+/// 2. With default `Debug` formatting for the reply.
+/// 3. With a customizable formatting function for the reply.
+///
+/// # Usage
+///
+/// ```ignore
+/// // No reply printing
+/// log_result!(method_call, "method_name", req);
+///
+/// // With default Debug formatting for the reply
+/// log_result!(method_call, "method_name", req, debug);
+///
+/// // With a custom formatting function for the reply
+/// log_result!(method_call, "method_name", req, custom_format_fn);
+/// ```
+///
+/// # Arguments
+///
+/// - `$method_call`: The asynchronous method call to execute and log.
+/// - `$method_name`: A string representing the name of the method for logging 
purposes.
+/// - `$req`: The incoming FUSE request associated with the method call.
+/// - `$format_reply_fn`: (Optional) A custom formatting function to describe 
the reply more specifically.
+macro_rules! log_result {
+   // No reply printing
+   ($method_call:expr, $method_name:expr, $req:ident) => {
+match $method_call.await {
+Ok(reply) => {
+debug!($req.unique, concat!($method_name, " completed"));
+Ok(reply)
+}
+Err(e) => {
+error!($req.unique, ?e, concat!($method_name, " failed"));
+Err(e)
+}
+}
+};
+
+// Default Debug formatting
+($method_call:expr, $method_name:expr, $req:ident, debug) => {
+match $method_call.await {
+Ok(reply) => {
+debug!($req.unique, ?reply, concat!($method_name, " 
completed"));
+Ok(reply)
+}
+Err(e) => {
+error!($req.unique, ?e, concat!($method_name, " failed"));
+Err(e)
+}
+}
+};
+
+// Format reply with custom formatting function
+($method_call:expr, $method_name:expr, $req:ident, $format_reply_fn:ident) 
=> {
+match $method_call.await {
+Ok(reply) => {
+debug!($req.unique, reply = %$format_reply_fn(&reply), 
concat!($method_name, " completed"));
+Ok(reply)
+}
+Err(e) => {
+error!($req.unique, ?e, concat!($method_name, " failed"));
+Err(e)
+}
+}
+};
+
+// Format stream with custom formatting function
+($method_call:expr, $method_name:expr, $req:ident, stream, 
$format_reply_fn:expr) => {{
+match $method_call.await {
+Ok(reply_dir) => {
+let mut stream = reply_dir.entries.peekable();
+let mut debug_output = String::new();
+while let Some(entry_result) = stream.peek().await {
+match entry_result {
+Ok(entry) => {
+debug_output.push_str(format!("Directory entry: 
{:?}\n", entry).as_str());
+}
+Err(e) => {
+debug_output.push_str(format!("Error reading 
directory entry: {:?}\n", e).as_str());
+  

Re: [PR] [#5873] feat(gvfs-fuse): add debug log for FuseApiHandle [gravitino]

2025-01-23 Thread via GitHub


unknowntpo commented on code in PR #5905:
URL: https://github.com/apache/gravitino/pull/5905#discussion_r1928006616


##
clients/filesystem-fuse/src/fuse_api_handle_debug.rs:
##
@@ -0,0 +1,737 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+use crate::config::AppConfig;
+use crate::filesystem::{FileSystemContext, RawFileSystem};
+use crate::fuse_api_handle::FuseApiHandle;
+use chrono::DateTime;
+use fuse3::path::prelude::{ReplyData, ReplyOpen, ReplyStatFs, ReplyWrite};
+use fuse3::path::Request;
+use fuse3::raw::prelude::{
+FileAttr, ReplyAttr, ReplyCreated, ReplyDirectory, ReplyDirectoryPlus, 
ReplyEntry, ReplyInit,
+};
+use fuse3::raw::reply::{DirectoryEntry, DirectoryEntryPlus};
+use fuse3::raw::Filesystem;
+use fuse3::{Inode, SetAttr, Timestamp};
+use futures_util::stream::{BoxStream};
+use futures_util::{StreamExt};
+use std::ffi::{OsStr};
+use std::fmt::Write;
+use tracing::{debug, error};
+
+/// A macro to log the result of an asynchronous method call in the context of 
FUSE operations.
+///
+/// This macro provides three variants for logging:
+/// 1. Without logging the reply (logs only the method status).
+/// 2. With default `Debug` formatting for the reply.
+/// 3. With a customizable formatting function for the reply.
+///
+/// # Usage
+///
+/// ```ignore
+/// // No reply printing
+/// log_result!(method_call, "method_name", req);
+///
+/// // With default Debug formatting for the reply
+/// log_result!(method_call, "method_name", req, debug);
+///
+/// // With a custom formatting function for the reply
+/// log_result!(method_call, "method_name", req, custom_format_fn);
+/// ```
+///
+/// # Arguments
+///
+/// - `$method_call`: The asynchronous method call to execute and log.
+/// - `$method_name`: A string representing the name of the method for logging 
purposes.
+/// - `$req`: The incoming FUSE request associated with the method call.
+/// - `$format_reply_fn`: (Optional) A custom formatting function to describe 
the reply more specifically.
+macro_rules! log_result {
+   // No reply printing
+   ($method_call:expr, $method_name:expr, $req:ident) => {
+match $method_call.await {
+Ok(reply) => {
+debug!($req.unique, concat!($method_name, " completed"));
+Ok(reply)
+}
+Err(e) => {
+error!($req.unique, ?e, concat!($method_name, " failed"));
+Err(e)
+}
+}
+};
+
+// Default Debug formatting
+($method_call:expr, $method_name:expr, $req:ident, debug) => {
+match $method_call.await {
+Ok(reply) => {
+debug!($req.unique, ?reply, concat!($method_name, " 
completed"));
+Ok(reply)
+}
+Err(e) => {
+error!($req.unique, ?e, concat!($method_name, " failed"));
+Err(e)
+}
+}
+};
+
+// Format reply with custom formatting function
+($method_call:expr, $method_name:expr, $req:ident, $format_reply_fn:ident) 
=> {
+match $method_call.await {
+Ok(reply) => {
+debug!($req.unique, reply = %$format_reply_fn(&reply), 
concat!($method_name, " completed"));
+Ok(reply)
+}
+Err(e) => {
+error!($req.unique, ?e, concat!($method_name, " failed"));
+Err(e)
+}
+}
+};
+
+// Format stream with custom formatting function
+($method_call:expr, $method_name:expr, $req:ident, stream, 
$format_reply_fn:expr) => {{
+match $method_call.await {
+Ok(reply_dir) => {
+let mut stream = reply_dir.entries.peekable();
+let mut debug_output = String::new();
+while let Some(entry_result) = stream.peek().await {
+match entry_result {
+Ok(entry) => {
+debug_output.push_str(format!("Directory entry: 
{:?}\n", entry).as_str());
+}
+Err(e) => {
+debug_output.push_str(format!("Error reading 
directory entry: {:?}\n", e).as_str());
+   

Re: [PR] [#5873] feat(gvfs-fuse): add debug log for FuseApiHandle [gravitino]

2025-01-23 Thread via GitHub


unknowntpo commented on code in PR #5905:
URL: https://github.com/apache/gravitino/pull/5905#discussion_r1928006616


##
clients/filesystem-fuse/src/fuse_api_handle_debug.rs:
##
@@ -0,0 +1,737 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+use crate::config::AppConfig;
+use crate::filesystem::{FileSystemContext, RawFileSystem};
+use crate::fuse_api_handle::FuseApiHandle;
+use chrono::DateTime;
+use fuse3::path::prelude::{ReplyData, ReplyOpen, ReplyStatFs, ReplyWrite};
+use fuse3::path::Request;
+use fuse3::raw::prelude::{
+FileAttr, ReplyAttr, ReplyCreated, ReplyDirectory, ReplyDirectoryPlus, 
ReplyEntry, ReplyInit,
+};
+use fuse3::raw::reply::{DirectoryEntry, DirectoryEntryPlus};
+use fuse3::raw::Filesystem;
+use fuse3::{Inode, SetAttr, Timestamp};
+use futures_util::stream::{BoxStream};
+use futures_util::{StreamExt};
+use std::ffi::{OsStr};
+use std::fmt::Write;
+use tracing::{debug, error};
+
+/// A macro to log the result of an asynchronous method call in the context of 
FUSE operations.
+///
+/// This macro provides three variants for logging:
+/// 1. Without logging the reply (logs only the method status).
+/// 2. With default `Debug` formatting for the reply.
+/// 3. With a customizable formatting function for the reply.
+///
+/// # Usage
+///
+/// ```ignore
+/// // No reply printing
+/// log_result!(method_call, "method_name", req);
+///
+/// // With default Debug formatting for the reply
+/// log_result!(method_call, "method_name", req, debug);
+///
+/// // With a custom formatting function for the reply
+/// log_result!(method_call, "method_name", req, custom_format_fn);
+/// ```
+///
+/// # Arguments
+///
+/// - `$method_call`: The asynchronous method call to execute and log.
+/// - `$method_name`: A string representing the name of the method for logging 
purposes.
+/// - `$req`: The incoming FUSE request associated with the method call.
+/// - `$format_reply_fn`: (Optional) A custom formatting function to describe 
the reply more specifically.
+macro_rules! log_result {
+   // No reply printing
+   ($method_call:expr, $method_name:expr, $req:ident) => {
+match $method_call.await {
+Ok(reply) => {
+debug!($req.unique, concat!($method_name, " completed"));
+Ok(reply)
+}
+Err(e) => {
+error!($req.unique, ?e, concat!($method_name, " failed"));
+Err(e)
+}
+}
+};
+
+// Default Debug formatting
+($method_call:expr, $method_name:expr, $req:ident, debug) => {
+match $method_call.await {
+Ok(reply) => {
+debug!($req.unique, ?reply, concat!($method_name, " 
completed"));
+Ok(reply)
+}
+Err(e) => {
+error!($req.unique, ?e, concat!($method_name, " failed"));
+Err(e)
+}
+}
+};
+
+// Format reply with custom formatting function
+($method_call:expr, $method_name:expr, $req:ident, $format_reply_fn:ident) 
=> {
+match $method_call.await {
+Ok(reply) => {
+debug!($req.unique, reply = %$format_reply_fn(&reply), 
concat!($method_name, " completed"));
+Ok(reply)
+}
+Err(e) => {
+error!($req.unique, ?e, concat!($method_name, " failed"));
+Err(e)
+}
+}
+};
+
+// Format stream with custom formatting function
+($method_call:expr, $method_name:expr, $req:ident, stream, 
$format_reply_fn:expr) => {{
+match $method_call.await {
+Ok(reply_dir) => {
+let mut stream = reply_dir.entries.peekable();
+let mut debug_output = String::new();
+while let Some(entry_result) = stream.peek().await {
+match entry_result {
+Ok(entry) => {
+debug_output.push_str(format!("Directory entry: 
{:?}\n", entry).as_str());
+}
+Err(e) => {
+debug_output.push_str(format!("Error reading 
directory entry: {:?}\n", e).as_str());
+   

Re: [PR] [#5873] feat(gvfs-fuse): add debug log for FuseApiHandle [gravitino]

2025-01-23 Thread via GitHub


unknowntpo commented on code in PR #5905:
URL: https://github.com/apache/gravitino/pull/5905#discussion_r1927999298


##
clients/filesystem-fuse/src/fuse_api_handle_debug.rs:
##
@@ -0,0 +1,737 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+use crate::config::AppConfig;
+use crate::filesystem::{FileSystemContext, RawFileSystem};
+use crate::fuse_api_handle::FuseApiHandle;
+use chrono::DateTime;
+use fuse3::path::prelude::{ReplyData, ReplyOpen, ReplyStatFs, ReplyWrite};
+use fuse3::path::Request;
+use fuse3::raw::prelude::{
+FileAttr, ReplyAttr, ReplyCreated, ReplyDirectory, ReplyDirectoryPlus, 
ReplyEntry, ReplyInit,
+};
+use fuse3::raw::reply::{DirectoryEntry, DirectoryEntryPlus};
+use fuse3::raw::Filesystem;
+use fuse3::{Inode, SetAttr, Timestamp};
+use futures_util::stream::{BoxStream};
+use futures_util::{StreamExt};
+use std::ffi::{OsStr};
+use std::fmt::Write;
+use tracing::{debug, error};
+
+/// A macro to log the result of an asynchronous method call in the context of 
FUSE operations.
+///
+/// This macro provides three variants for logging:
+/// 1. Without logging the reply (logs only the method status).
+/// 2. With default `Debug` formatting for the reply.
+/// 3. With a customizable formatting function for the reply.
+///
+/// # Usage
+///
+/// ```ignore
+/// // No reply printing
+/// log_result!(method_call, "method_name", req);
+///
+/// // With default Debug formatting for the reply
+/// log_result!(method_call, "method_name", req, debug);
+///
+/// // With a custom formatting function for the reply
+/// log_result!(method_call, "method_name", req, custom_format_fn);
+/// ```
+///
+/// # Arguments
+///
+/// - `$method_call`: The asynchronous method call to execute and log.
+/// - `$method_name`: A string representing the name of the method for logging 
purposes.
+/// - `$req`: The incoming FUSE request associated with the method call.
+/// - `$format_reply_fn`: (Optional) A custom formatting function to describe 
the reply more specifically.
+macro_rules! log_result {
+   // No reply printing
+   ($method_call:expr, $method_name:expr, $req:ident) => {
+match $method_call.await {
+Ok(reply) => {
+debug!($req.unique, concat!($method_name, " completed"));
+Ok(reply)
+}
+Err(e) => {
+error!($req.unique, ?e, concat!($method_name, " failed"));
+Err(e)
+}
+}
+};
+
+// Default Debug formatting
+($method_call:expr, $method_name:expr, $req:ident, debug) => {
+match $method_call.await {
+Ok(reply) => {
+debug!($req.unique, ?reply, concat!($method_name, " 
completed"));
+Ok(reply)
+}
+Err(e) => {
+error!($req.unique, ?e, concat!($method_name, " failed"));
+Err(e)
+}
+}
+};
+
+// Format reply with custom formatting function
+($method_call:expr, $method_name:expr, $req:ident, $format_reply_fn:ident) 
=> {
+match $method_call.await {
+Ok(reply) => {
+debug!($req.unique, reply = %$format_reply_fn(&reply), 
concat!($method_name, " completed"));
+Ok(reply)
+}
+Err(e) => {
+error!($req.unique, ?e, concat!($method_name, " failed"));
+Err(e)
+}
+}
+};
+
+// Format stream with custom formatting function
+($method_call:expr, $method_name:expr, $req:ident, stream, 
$format_reply_fn:expr) => {{
+match $method_call.await {
+Ok(reply_dir) => {
+let mut stream = reply_dir.entries.peekable();
+let mut debug_output = String::new();
+while let Some(entry_result) = stream.peek().await {
+match entry_result {
+Ok(entry) => {
+debug_output.push_str(format!("Directory entry: 
{:?}\n", entry).as_str());
+}
+Err(e) => {
+debug_output.push_str(format!("Error reading 
directory entry: {:?}\n", e).as_str());
+   

Re: [PR] [#5873] feat(gvfs-fuse): add debug log for FuseApiHandle [gravitino]

2025-01-23 Thread via GitHub


diqiu50 commented on code in PR #5905:
URL: https://github.com/apache/gravitino/pull/5905#discussion_r1927986717


##
clients/filesystem-fuse/src/fuse_api_handle_debug.rs:
##
@@ -0,0 +1,737 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+use crate::config::AppConfig;
+use crate::filesystem::{FileSystemContext, RawFileSystem};
+use crate::fuse_api_handle::FuseApiHandle;
+use chrono::DateTime;
+use fuse3::path::prelude::{ReplyData, ReplyOpen, ReplyStatFs, ReplyWrite};
+use fuse3::path::Request;
+use fuse3::raw::prelude::{
+FileAttr, ReplyAttr, ReplyCreated, ReplyDirectory, ReplyDirectoryPlus, 
ReplyEntry, ReplyInit,
+};
+use fuse3::raw::reply::{DirectoryEntry, DirectoryEntryPlus};
+use fuse3::raw::Filesystem;
+use fuse3::{Inode, SetAttr, Timestamp};
+use futures_util::stream::{BoxStream};
+use futures_util::{StreamExt};
+use std::ffi::{OsStr};
+use std::fmt::Write;
+use tracing::{debug, error};
+
+/// A macro to log the result of an asynchronous method call in the context of 
FUSE operations.
+///
+/// This macro provides three variants for logging:
+/// 1. Without logging the reply (logs only the method status).
+/// 2. With default `Debug` formatting for the reply.
+/// 3. With a customizable formatting function for the reply.
+///
+/// # Usage
+///
+/// ```ignore
+/// // No reply printing
+/// log_result!(method_call, "method_name", req);
+///
+/// // With default Debug formatting for the reply
+/// log_result!(method_call, "method_name", req, debug);
+///
+/// // With a custom formatting function for the reply
+/// log_result!(method_call, "method_name", req, custom_format_fn);
+/// ```
+///
+/// # Arguments
+///
+/// - `$method_call`: The asynchronous method call to execute and log.
+/// - `$method_name`: A string representing the name of the method for logging 
purposes.
+/// - `$req`: The incoming FUSE request associated with the method call.
+/// - `$format_reply_fn`: (Optional) A custom formatting function to describe 
the reply more specifically.
+macro_rules! log_result {
+   // No reply printing
+   ($method_call:expr, $method_name:expr, $req:ident) => {
+match $method_call.await {
+Ok(reply) => {
+debug!($req.unique, concat!($method_name, " completed"));
+Ok(reply)
+}
+Err(e) => {
+error!($req.unique, ?e, concat!($method_name, " failed"));
+Err(e)
+}
+}
+};
+
+// Default Debug formatting
+($method_call:expr, $method_name:expr, $req:ident, debug) => {
+match $method_call.await {
+Ok(reply) => {
+debug!($req.unique, ?reply, concat!($method_name, " 
completed"));
+Ok(reply)
+}
+Err(e) => {
+error!($req.unique, ?e, concat!($method_name, " failed"));
+Err(e)
+}
+}
+};
+
+// Format reply with custom formatting function
+($method_call:expr, $method_name:expr, $req:ident, $format_reply_fn:ident) 
=> {
+match $method_call.await {
+Ok(reply) => {
+debug!($req.unique, reply = %$format_reply_fn(&reply), 
concat!($method_name, " completed"));
+Ok(reply)
+}
+Err(e) => {
+error!($req.unique, ?e, concat!($method_name, " failed"));
+Err(e)
+}
+}
+};
+
+// Format stream with custom formatting function
+($method_call:expr, $method_name:expr, $req:ident, stream, 
$format_reply_fn:expr) => {{
+match $method_call.await {
+Ok(reply_dir) => {
+let mut stream = reply_dir.entries.peekable();
+let mut debug_output = String::new();
+while let Some(entry_result) = stream.peek().await {
+match entry_result {
+Ok(entry) => {
+debug_output.push_str(format!("Directory entry: 
{:?}\n", entry).as_str());
+}
+Err(e) => {
+debug_output.push_str(format!("Error reading 
directory entry: {:?}\n", e).as_str());
+  

Re: [PR] [#5873] feat(gvfs-fuse): add debug log for FuseApiHandle [gravitino]

2025-01-22 Thread via GitHub


unknowntpo commented on code in PR #5905:
URL: https://github.com/apache/gravitino/pull/5905#discussion_r1926268456


##
clients/filesystem-fuse/src/fuse_api_handle_debug.rs:
##
@@ -0,0 +1,737 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+use crate::config::AppConfig;
+use crate::filesystem::{FileSystemContext, RawFileSystem};
+use crate::fuse_api_handle::FuseApiHandle;
+use chrono::DateTime;
+use fuse3::path::prelude::{ReplyData, ReplyOpen, ReplyStatFs, ReplyWrite};
+use fuse3::path::Request;
+use fuse3::raw::prelude::{
+FileAttr, ReplyAttr, ReplyCreated, ReplyDirectory, ReplyDirectoryPlus, 
ReplyEntry, ReplyInit,
+};
+use fuse3::raw::reply::{DirectoryEntry, DirectoryEntryPlus};
+use fuse3::raw::Filesystem;
+use fuse3::{Inode, SetAttr, Timestamp};
+use futures_util::stream::{BoxStream};
+use futures_util::{StreamExt};
+use std::ffi::{OsStr};
+use std::fmt::Write;
+use tracing::{debug, error};
+
+/// A macro to log the result of an asynchronous method call in the context of 
FUSE operations.
+///
+/// This macro provides three variants for logging:
+/// 1. Without logging the reply (logs only the method status).
+/// 2. With default `Debug` formatting for the reply.
+/// 3. With a customizable formatting function for the reply.
+///
+/// # Usage
+///
+/// ```ignore
+/// // No reply printing
+/// log_result!(method_call, "method_name", req);
+///
+/// // With default Debug formatting for the reply
+/// log_result!(method_call, "method_name", req, debug);
+///
+/// // With a custom formatting function for the reply
+/// log_result!(method_call, "method_name", req, custom_format_fn);
+/// ```
+///
+/// # Arguments
+///
+/// - `$method_call`: The asynchronous method call to execute and log.
+/// - `$method_name`: A string representing the name of the method for logging 
purposes.
+/// - `$req`: The incoming FUSE request associated with the method call.
+/// - `$format_reply_fn`: (Optional) A custom formatting function to describe 
the reply more specifically.
+macro_rules! log_result {
+   // No reply printing
+   ($method_call:expr, $method_name:expr, $req:ident) => {
+match $method_call.await {
+Ok(reply) => {
+debug!($req.unique, concat!($method_name, " completed"));
+Ok(reply)
+}
+Err(e) => {
+error!($req.unique, ?e, concat!($method_name, " failed"));
+Err(e)
+}
+}
+};
+
+// Default Debug formatting
+($method_call:expr, $method_name:expr, $req:ident, debug) => {
+match $method_call.await {
+Ok(reply) => {
+debug!($req.unique, ?reply, concat!($method_name, " 
completed"));
+Ok(reply)
+}
+Err(e) => {
+error!($req.unique, ?e, concat!($method_name, " failed"));
+Err(e)
+}
+}
+};
+
+// Format reply with custom formatting function
+($method_call:expr, $method_name:expr, $req:ident, $format_reply_fn:ident) 
=> {
+match $method_call.await {
+Ok(reply) => {
+debug!($req.unique, reply = %$format_reply_fn(&reply), 
concat!($method_name, " completed"));
+Ok(reply)
+}
+Err(e) => {
+error!($req.unique, ?e, concat!($method_name, " failed"));
+Err(e)
+}
+}
+};
+
+// Format stream with custom formatting function
+($method_call:expr, $method_name:expr, $req:ident, stream, 
$format_reply_fn:expr) => {{
+match $method_call.await {
+Ok(reply_dir) => {
+let mut stream = reply_dir.entries.peekable();
+let mut debug_output = String::new();
+while let Some(entry_result) = stream.peek().await {
+match entry_result {
+Ok(entry) => {
+debug_output.push_str(format!("Directory entry: 
{:?}\n", entry).as_str());
+}
+Err(e) => {
+debug_output.push_str(format!("Error reading 
directory entry: {:?}\n", e).as_str());
+   

Re: [PR] [#5873] feat(gvfs-fuse): add debug log for FuseApiHandle [gravitino]

2025-01-22 Thread via GitHub


unknowntpo commented on code in PR #5905:
URL: https://github.com/apache/gravitino/pull/5905#discussion_r1926268456


##
clients/filesystem-fuse/src/fuse_api_handle_debug.rs:
##
@@ -0,0 +1,737 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+use crate::config::AppConfig;
+use crate::filesystem::{FileSystemContext, RawFileSystem};
+use crate::fuse_api_handle::FuseApiHandle;
+use chrono::DateTime;
+use fuse3::path::prelude::{ReplyData, ReplyOpen, ReplyStatFs, ReplyWrite};
+use fuse3::path::Request;
+use fuse3::raw::prelude::{
+FileAttr, ReplyAttr, ReplyCreated, ReplyDirectory, ReplyDirectoryPlus, 
ReplyEntry, ReplyInit,
+};
+use fuse3::raw::reply::{DirectoryEntry, DirectoryEntryPlus};
+use fuse3::raw::Filesystem;
+use fuse3::{Inode, SetAttr, Timestamp};
+use futures_util::stream::{BoxStream};
+use futures_util::{StreamExt};
+use std::ffi::{OsStr};
+use std::fmt::Write;
+use tracing::{debug, error};
+
+/// A macro to log the result of an asynchronous method call in the context of 
FUSE operations.
+///
+/// This macro provides three variants for logging:
+/// 1. Without logging the reply (logs only the method status).
+/// 2. With default `Debug` formatting for the reply.
+/// 3. With a customizable formatting function for the reply.
+///
+/// # Usage
+///
+/// ```ignore
+/// // No reply printing
+/// log_result!(method_call, "method_name", req);
+///
+/// // With default Debug formatting for the reply
+/// log_result!(method_call, "method_name", req, debug);
+///
+/// // With a custom formatting function for the reply
+/// log_result!(method_call, "method_name", req, custom_format_fn);
+/// ```
+///
+/// # Arguments
+///
+/// - `$method_call`: The asynchronous method call to execute and log.
+/// - `$method_name`: A string representing the name of the method for logging 
purposes.
+/// - `$req`: The incoming FUSE request associated with the method call.
+/// - `$format_reply_fn`: (Optional) A custom formatting function to describe 
the reply more specifically.
+macro_rules! log_result {
+   // No reply printing
+   ($method_call:expr, $method_name:expr, $req:ident) => {
+match $method_call.await {
+Ok(reply) => {
+debug!($req.unique, concat!($method_name, " completed"));
+Ok(reply)
+}
+Err(e) => {
+error!($req.unique, ?e, concat!($method_name, " failed"));
+Err(e)
+}
+}
+};
+
+// Default Debug formatting
+($method_call:expr, $method_name:expr, $req:ident, debug) => {
+match $method_call.await {
+Ok(reply) => {
+debug!($req.unique, ?reply, concat!($method_name, " 
completed"));
+Ok(reply)
+}
+Err(e) => {
+error!($req.unique, ?e, concat!($method_name, " failed"));
+Err(e)
+}
+}
+};
+
+// Format reply with custom formatting function
+($method_call:expr, $method_name:expr, $req:ident, $format_reply_fn:ident) 
=> {
+match $method_call.await {
+Ok(reply) => {
+debug!($req.unique, reply = %$format_reply_fn(&reply), 
concat!($method_name, " completed"));
+Ok(reply)
+}
+Err(e) => {
+error!($req.unique, ?e, concat!($method_name, " failed"));
+Err(e)
+}
+}
+};
+
+// Format stream with custom formatting function
+($method_call:expr, $method_name:expr, $req:ident, stream, 
$format_reply_fn:expr) => {{
+match $method_call.await {
+Ok(reply_dir) => {
+let mut stream = reply_dir.entries.peekable();
+let mut debug_output = String::new();
+while let Some(entry_result) = stream.peek().await {
+match entry_result {
+Ok(entry) => {
+debug_output.push_str(format!("Directory entry: 
{:?}\n", entry).as_str());
+}
+Err(e) => {
+debug_output.push_str(format!("Error reading 
directory entry: {:?}\n", e).as_str());
+   

Re: [PR] [#5873] feat(gvfs-fuse): add debug log for FuseApiHandle [gravitino]

2025-01-19 Thread via GitHub


unknowntpo commented on PR #5905:
URL: https://github.com/apache/gravitino/pull/5905#issuecomment-2601196573

   Ok, I can put them in the same line like this
   
   ```
   2025-01-20T10:00:00.123456Z INFO directory_listing: [{ inode: 10001, kind: 
Directory, name: ".", offset: 1 },  
   { inode: 1, kind: Directory, name: "..", offset: 2 }, { inode: 10002, kind: 
RegularFile, name: "test_file", offset: 3 }]
   ```


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]



Re: [PR] [#5873] feat(gvfs-fuse): add debug log for FuseApiHandle [gravitino]

2025-01-19 Thread via GitHub


diqiu50 commented on PR #5905:
URL: https://github.com/apache/gravitino/pull/5905#issuecomment-2601191204

   We need to print the directory list on a single line; otherwise, it’s hard 
to tell which request the result belongs to.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]



Re: [PR] [#5873] feat(gvfs-fuse): add debug log for FuseApiHandle [gravitino]

2025-01-19 Thread via GitHub


unknowntpo commented on PR #5905:
URL: https://github.com/apache/gravitino/pull/5905#issuecomment-2601181334

   @diqiu50 
   
   This is the new format I came up with:
   
   1. Print filename in separate kv pair, because filename might include `()`, 
it's not ok to mix them.
   2. Manually print necessary info about `Request`, not rely on `Debug` trait.
   3. In reply, we print status first
   4. See the example below
   
   ```
   GETATTR started req.unique=8 filename="test_dir" file_id=10002 uid=501 
gid=20 pid=20058 fh=None flags=0
   2025-01-18T11:14:55.473292Z DEBUG gvfs_fuse::fuse_api_handle_debug: GETATTR 
completed req.unique=8 reply=ttl: 1s, FileAttr: { ino: 10002, size: 0, blocks: 
0, atime: "2025-01-18 11:14:55.473280", mtime: "2025-01-18 11:14:55.473280", 
ctime: "2025-01-18 11:14:55.473280", crtime: "2025-01-18 11:14:55.473280", 
kind: Directory, perm: 700, nlink: 1, uid: 501, gid: 20, rdev: 0, flags: 0, 
blksize: 8192 }
   
   ...
   ## For directory listing
   2025-01-20T10:00:00.123456Z INFO directory_listing: Directory entry: { 
inode: 10001, kind: Directory, name: ".", offset: 1 }
   2025-01-20T10:00:00.123457Z INFO directory_listing: Directory entry: { 
inode: 1, kind: Directory, name: "..", offset: 2 }
   2025-01-20T10:00:00.123458Z INFO directory_listing: Directory entry: { 
inode: 10002, kind: RegularFile, name: "test_file", offset: 3 }
   ```


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]



Re: [PR] [#5873] feat(gvfs-fuse): add debug log for FuseApiHandle [gravitino]

2025-01-16 Thread via GitHub


diqiu50 commented on code in PR #5905:
URL: https://github.com/apache/gravitino/pull/5905#discussion_r1918026613


##
clients/filesystem-fuse/src/fuse_api_handle.rs:
##
@@ -30,10 +30,174 @@ use fuse3::{Errno, FileType, Inode, SetAttr, Timestamp};
 use futures_util::stream;
 use futures_util::stream::BoxStream;
 use futures_util::StreamExt;
+use log::debug;
 use std::ffi::{OsStr, OsString};
 use std::num::NonZeroU32;
 use std::time::{Duration, SystemTime};
 
+pub(crate) struct FuseApiHandleDebug {
+inner: FuseApiHandle,
+}
+
+impl FuseApiHandleDebug {
+pub fn new(fs: T, context: FileSystemContext) -> Self {
+Self {
+inner: FuseApiHandle::new(fs, context),
+}
+}
+
+pub async fn get_file_path(&self, file_id: u64) -> String {
+debug!("get_file_path: file_id: {}", file_id);
+let result = self.inner.get_file_path(file_id).await;
+debug!("get_file_path result: {}", result);
+result
+}
+
+async fn get_modified_file_stat(
+&self,
+file_id: u64,
+size: Option,
+atime: Option,
+mtime: Option,
+) -> Result {
+debug!("get_modified_file_stat: file_id: {}, size: {:?}, atime: {:?}, 
mtime: {:?}", file_id, size, atime, mtime);
+let result = self.inner.get_modified_file_stat(file_id, size, atime, 
mtime).await;
+debug!("get_modified_file_stat result: {:?}", result);
+result
+}
+}
+
+impl Filesystem for FuseApiHandleDebug {
+async fn init(&self, req: Request) -> fuse3::Result {

Review Comment:
   Do you implement all the Filesystem interfaces?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]



Re: [PR] [#5873] feat(gvfs-fuse): add debug log for FuseApiHandle [gravitino]

2025-01-16 Thread via GitHub


diqiu50 commented on code in PR #5905:
URL: https://github.com/apache/gravitino/pull/5905#discussion_r1917878392


##
clients/filesystem-fuse/conf/gvfs_fuse.toml:
##
@@ -20,6 +20,7 @@
 file_mask = 0o600
 dir_mask = 0o700
 fs_type = "memory"
+fuse_debug=true
 

Review Comment:
   Keep the format 



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]



Re: [PR] [#5873] feat(gvfs-fuse): add debug log for FuseApiHandle [gravitino]

2025-01-16 Thread via GitHub


diqiu50 commented on PR #5905:
URL: https://github.com/apache/gravitino/pull/5905#issuecomment-2594813907

   ```
   
   2025-01-16T08:22:33.123544Z DEBUG gvfs_fuse::fuse_api_handle_debug: getattr 
started req.unique=6 req=Request { unique: 6, uid: 1000, gid: 1000, pid: 52525 
} filename="" fh=None flags=0
   2025-01-16T08:22:33.124241Z DEBUG gvfs_fuse::fuse_api_handle_debug: getattr 
completed req.unique=6 reply=ttl: 1s, FileAttr: { ino: 1, size: 0, blocks: 0, 
atime: "2025-01-16 08:22:33.124094186", mtime: "2025-01-16 08:22:33.124094186", 
ctime: "2025-01-16 08:22:33.124094186", kind: Directory, perm: 700, nlink: 1, 
uid: 1000, gid: 1000, rdev: 0, blksize: 8192 }
   2025-01-16T08:22:37.450601Z DEBUG gvfs_fuse::fuse_api_handle_debug: getattr 
started req.unique=8 req=Request { unique: 8, uid: 1000, gid: 1000, pid: 34160 
} filename="" fh=None flags=0
   2025-01-16T08:22:37.450703Z DEBUG gvfs_fuse::fuse_api_handle_debug: getattr 
completed req.unique=8 reply=ttl: 1s, FileAttr: { ino: 1, size: 0, blocks: 0, 
atime: "2025-01-16 08:22:37.450669378", mtime: "2025-01-16 08:22:37.450669378", 
ctime: "2025-01-16 08:22:37.450669378", kind: Directory, perm: 700, nlink: 1, 
uid: 1000, gid: 1000, rdev: 0, blksize: 8192 }
   2025-01-16T08:22:58.586380Z DEBUG gvfs_fuse::fuse_api_handle_debug: opendir 
started req.unique=12 req=Request { unique: 12, uid: 1000, gid: 1000, pid: 
52567 } dirname="" flags=100352
   2025-01-16T08:22:58.586514Z DEBUG gvfs_fuse::fuse_api_handle_debug: opendir 
completed req.unique=12 reply=ReplyOpen { fh: 1, flags: 100352 }
   2025-01-16T08:22:58.586744Z DEBUG gvfs_fuse::fuse_api_handle_debug: getattr 
started req.unique=14 req=Request { unique: 14, uid: 1000, gid: 1000, pid: 
52567 } filename="" fh=None flags=0
   2025-01-16T08:22:58.586815Z DEBUG gvfs_fuse::fuse_api_handle_debug: getattr 
completed req.unique=14 reply=ttl: 1s, FileAttr: { ino: 1, size: 0, blocks: 0, 
atime: "2025-01-16 08:22:58.586782325", mtime: "2025-01-16 08:22:58.586782325", 
ctime: "2025-01-16 08:22:58.586782325", kind: Directory, perm: 700, nlink: 1, 
uid: 1000, gid: 1000, rdev: 0, blksize: 8192 }
   2025-01-16T08:22:58.587054Z DEBUG gvfs_fuse::fuse_api_handle_debug: 
readdirplus started req.unique=16 req=Request { unique: 16, uid: 1000, gid: 
1000, pid: 52567 } parent=1 fh=1 offset=0 lock_owner=0
   2025-01-16T08:22:58.587117Z DEBUG gvfs_fuse::fuse_api_handle_debug: 
readdirplus completed req.unique=16
   2025-01-16T08:22:58.587846Z DEBUG gvfs_fuse::fuse_api_handle_debug: 
readdirplus started req.unique=20 req=Request { unique: 20, uid: 1000, gid: 
1000, pid: 52567 } parent=1 fh=1 offset=3 lock_owner=0
   2025-01-16T08:22:58.587914Z DEBUG gvfs_fuse::fuse_api_handle_debug: 
readdirplus completed req.unique=20
   2025-01-16T08:22:58.588132Z DEBUG gvfs_fuse::fuse_api_handle_debug: 
releasedir started req.unique=22 req=Request { unique: 22, uid: 0, gid: 0, pid: 
0 } dirname="" fh=1 flags=100352
   2025-01-16T08:22:58.588192Z DEBUG gvfs_fuse::fuse_api_handle_debug: 
releasedir completed req.unique=22
   2025-01-16T08:23:49.754919Z DEBUG gvfs_fuse::fuse_api_handle_debug: lookup 
started req.unique=24 req=Request { unique: 24, uid: 1000, gid: 1000, pid: 
34160 } parent="" name="e"
   2025-01-16T08:23:49.754998Z ERROR gvfs_fuse::fuse_api_handle_debug: lookup 
failed req.unique=24 e=Errno(2)
   2025-01-16T08:23:49.755206Z DEBUG gvfs_fuse::fuse_api_handle_debug: getattr 
started req.unique=26 req=Request { unique: 26, uid: 1000, gid: 1000, pid: 
34160 } filename="" fh=None flags=0
   2025-01-16T08:23:49.755284Z DEBUG gvfs_fuse::fuse_api_handle_debug: getattr 
completed req.unique=26 reply=ttl: 1s, FileAttr: { ino: 1, size: 0, blocks: 0, 
atime: "2025-01-16 08:23:49.755245615", mtime: "2025-01-16 08:23:49.755245615", 
ctime: "2025-01-16 08:23:49.755245615", kind: Directory, perm: 700, nlink: 1, 
uid: 1000, gid: 1000, rdev: 0, blksize: 8192 }
   2025-01-16T08:23:49.755502Z DEBUG gvfs_fuse::fuse_api_handle_debug: opendir 
started req.unique=28 req=Request { unique: 28, uid: 1000, gid: 1000, pid: 
34160 } dirname="" flags=100352
   2025-01-16T08:23:49.755570Z DEBUG gvfs_fuse::fuse_api_handle_debug: opendir 
completed req.unique=28 reply=ReplyOpen { fh: 2, flags: 100352 }
   2025-01-16T08:23:49.755720Z DEBUG gvfs_fuse::fuse_api_handle_debug: 
readdirplus started req.unique=30 req=Request { unique: 30, uid: 1000, gid: 
1000, pid: 34160 } parent=1 fh=2 offset=0 lock_owner=0
   2025-01-16T08:23:49.755783Z DEBUG gvfs_fuse::fuse_api_handle_debug: 
readdirplus completed req.unique=30
   2025-01-16T08:23:49.756008Z DEBUG gvfs_fuse::fuse_api_handle_debug: readdir 
started req.unique=32 req=Request { unique: 32, uid: 1000, gid: 1000, pid: 
34160 } parent="" fh=2 offset=3
   2025-01-16T08:23:49.756062Z DEBUG gvfs_fuse::fuse_api_handle_debug: readdir 
completed req.unique=32
   2025-01-16T08:23:49.756224Z DEBUG gvfs_fuse::fuse_api_handle_debug: 
releasedir started req.unique=34 req=Request { unique: 34, uid: 0, gid: 0, pid: 
0 } dirname="" f

Re: [PR] [#5873] feat(gvfs-fuse): add debug log for FuseApiHandle [gravitino]

2025-01-16 Thread via GitHub


diqiu50 commented on code in PR #5905:
URL: https://github.com/apache/gravitino/pull/5905#discussion_r1917926855


##
clients/filesystem-fuse/src/fuse_api_handle_debug.rs:
##
@@ -0,0 +1,584 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+use crate::config::AppConfig;
+use crate::filesystem::{FileSystemContext, RawFileSystem};
+use crate::fuse_api_handle::FuseApiHandle;
+use chrono::DateTime;
+use fuse3::path::prelude::{ReplyData, ReplyOpen, ReplyStatFs, ReplyWrite};
+use fuse3::path::Request;
+use fuse3::raw::prelude::{
+FileAttr, ReplyAttr, ReplyCreated, ReplyDirectory, ReplyDirectoryPlus, 
ReplyEntry, ReplyInit,
+};
+use fuse3::raw::reply::{DirectoryEntry, DirectoryEntryPlus};
+use fuse3::raw::Filesystem;
+use fuse3::{Inode, SetAttr, Timestamp};
+use futures_util::stream::BoxStream;
+use std::ffi::OsStr;
+use std::fmt::Write;
+use tracing::{debug, error};
+
+/// A macro to log the result of an asynchronous method call in the context of 
FUSE operations.
+///
+/// This macro provides three variants for logging:
+/// 1. Without logging the reply (logs only the method status).
+/// 2. With default `Debug` formatting for the reply.
+/// 3. With a customizable formatting function for the reply.
+///
+/// # Usage
+///
+/// ```ignore
+/// // No reply printing
+/// log_result!(method_call, "method_name", req);
+///
+/// // With default Debug formatting for the reply
+/// log_result!(method_call, "method_name", req, debug);
+///
+/// // With a custom formatting function for the reply
+/// log_result!(method_call, "method_name", req, custom_format_fn);
+/// ```
+///
+/// # Arguments
+///
+/// - `$method_call`: The asynchronous method call to execute and log.
+/// - `$method_name`: A string representing the name of the method for logging 
purposes.
+/// - `$req`: The incoming FUSE request associated with the method call.
+/// - `$format_reply_fn`: (Optional) A custom formatting function to describe 
the reply more specifically.
+macro_rules! log_result {
+   // No reply printing
+   ($method_call:expr, $method_name:expr, $req:ident) => {
+match $method_call.await {
+Ok(reply) => {
+debug!($req.unique, concat!($method_name, " completed"));
+Ok(reply)
+}
+Err(e) => {
+error!($req.unique, ?e, concat!($method_name, " failed"));
+Err(e)
+}
+}
+};
+
+// Default Debug formatting
+($method_call:expr, $method_name:expr, $req:ident, debug) => {
+match $method_call.await {
+Ok(reply) => {
+debug!($req.unique, ?reply, concat!($method_name, " 
completed"));
+Ok(reply)
+}
+Err(e) => {
+error!($req.unique, ?e, concat!($method_name, " failed"));
+Err(e)
+}
+}
+};
+
+// Format reply with custom format function
+($method_call:expr, $method_name:expr, $req:ident, $format_reply_fn:ident) 
=> {
+match $method_call.await {
+Ok(reply) => {
+debug!($req.unique, reply = %$format_reply_fn(&reply), 
concat!($method_name, " completed"));
+Ok(reply)
+}
+Err(e) => {
+error!($req.unique, ?e, concat!($method_name, " failed"));
+Err(e)
+}
+}
+};
+}
+
+/// Convert `ReplyAttr` to descriptive string.
+///
+/// Example: `ttl: 1s, FileAttr: { ino: 1, size: 0, blocks: 0, atime: 
"2025-01-16 02:42:52.600436", mtime: "2025-01-16 02:42:52.600436", ctime: 
"2025-01-16 02:42:52.600436", crtime: "2025-01-16 02:42:52.600436", kind: 
RegularFile, perm: 600, nlink: 1, uid: 501, gid: 20, rdev: 0, flags: 0, 
blksize: 8192 }`
+fn reply_attr_to_desc_str(reply_attr: &ReplyAttr) -> String {
+let mut output = String::new();
+
+write!(output, "ttl: {:?}, ", reply_attr.ttl).unwrap();
+write!(
+output,
+"FileAttr: {}",
+file_attr_to_desc_str(&reply_attr.attr)
+)
+.unwrap();
+
+output
+}
+
+/// Convert `ReplyEntry` to descriptive string.
+///
+/// Example: `ttl: 1s, FileAttr: { ino: 10001, size: 0, blocks: 1, atime: 
"2025-0

Re: [PR] [#5873] feat(gvfs-fuse): add debug log for FuseApiHandle [gravitino]

2025-01-16 Thread via GitHub


diqiu50 commented on code in PR #5905:
URL: https://github.com/apache/gravitino/pull/5905#discussion_r1917885027


##
clients/filesystem-fuse/src/config.rs:
##
@@ -265,6 +265,8 @@ pub struct FuseConfig {
 #[serde(default)]
 pub fs_type: String,
 #[serde(default)]
+pub fuse_debug: bool,
+#[serde(default)]

Review Comment:
   Need to handle default value like other configurations.



##
clients/filesystem-fuse/Cargo.toml:
##
@@ -46,6 +47,7 @@ opendal = { version = "0.46.0", features = ["services-s3"] }
 reqwest = { version = "0.12.9", features = ["json"] }
 serde = { version = "1.0.216", features = ["derive"] }
 tokio = { version = "1.38.0", features = ["full"] }
+tracing = "0.1.41"

Review Comment:
   If you want to use `tracing` instead of `log`, please remove `log`.



##
clients/filesystem-fuse/src/fuse_api_handle.rs:
##
@@ -53,7 +53,7 @@ impl FuseApiHandle {
 }
 }
 
-async fn get_modified_file_stat(
+pub async fn get_modified_file_stat(
 &self,

Review Comment:
   Don't use this function to retrieve the file name. use the 
`RawFileSystem::get_file_path` 



##
clients/filesystem-fuse/src/fuse_api_handle_debug.rs:
##
@@ -0,0 +1,584 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+use crate::config::AppConfig;
+use crate::filesystem::{FileSystemContext, RawFileSystem};
+use crate::fuse_api_handle::FuseApiHandle;
+use chrono::DateTime;
+use fuse3::path::prelude::{ReplyData, ReplyOpen, ReplyStatFs, ReplyWrite};
+use fuse3::path::Request;
+use fuse3::raw::prelude::{
+FileAttr, ReplyAttr, ReplyCreated, ReplyDirectory, ReplyDirectoryPlus, 
ReplyEntry, ReplyInit,
+};
+use fuse3::raw::reply::{DirectoryEntry, DirectoryEntryPlus};
+use fuse3::raw::Filesystem;
+use fuse3::{Inode, SetAttr, Timestamp};
+use futures_util::stream::BoxStream;
+use std::ffi::OsStr;
+use std::fmt::Write;
+use tracing::{debug, error};
+
+/// A macro to log the result of an asynchronous method call in the context of 
FUSE operations.
+///
+/// This macro provides three variants for logging:
+/// 1. Without logging the reply (logs only the method status).
+/// 2. With default `Debug` formatting for the reply.
+/// 3. With a customizable formatting function for the reply.
+///
+/// # Usage
+///
+/// ```ignore
+/// // No reply printing
+/// log_result!(method_call, "method_name", req);
+///
+/// // With default Debug formatting for the reply
+/// log_result!(method_call, "method_name", req, debug);
+///
+/// // With a custom formatting function for the reply
+/// log_result!(method_call, "method_name", req, custom_format_fn);
+/// ```
+///
+/// # Arguments
+///
+/// - `$method_call`: The asynchronous method call to execute and log.
+/// - `$method_name`: A string representing the name of the method for logging 
purposes.
+/// - `$req`: The incoming FUSE request associated with the method call.
+/// - `$format_reply_fn`: (Optional) A custom formatting function to describe 
the reply more specifically.
+macro_rules! log_result {
+   // No reply printing
+   ($method_call:expr, $method_name:expr, $req:ident) => {
+match $method_call.await {
+Ok(reply) => {
+debug!($req.unique, concat!($method_name, " completed"));
+Ok(reply)
+}
+Err(e) => {
+error!($req.unique, ?e, concat!($method_name, " failed"));
+Err(e)
+}
+}
+};
+
+// Default Debug formatting
+($method_call:expr, $method_name:expr, $req:ident, debug) => {
+match $method_call.await {
+Ok(reply) => {
+debug!($req.unique, ?reply, concat!($method_name, " 
completed"));
+Ok(reply)
+}
+Err(e) => {
+error!($req.unique, ?e, concat!($method_name, " failed"));
+Err(e)
+}
+}
+};
+
+// Format reply with custom format function
+($method_call:expr, $method_name:expr, $req:ident, $format_reply_fn:ident) 
=> {
+match $method_call.await {
+Ok(reply) => {
+debug!($req.unique, reply = %$format_reply_fn(&reply), 
c

Re: [PR] [#5873] feat(gvfs-fuse): add debug log for FuseApiHandle [gravitino]

2025-01-15 Thread via GitHub


unknowntpo commented on PR #5905:
URL: https://github.com/apache/gravitino/pull/5905#issuecomment-2594391206

   @diqiu50 Done, please take a look.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]



Re: [PR] [#5873] feat(gvfs-fuse): add debug log for FuseApiHandle [gravitino]

2025-01-15 Thread via GitHub


unknowntpo commented on code in PR #5905:
URL: https://github.com/apache/gravitino/pull/5905#discussion_r1917598800


##
clients/filesystem-fuse/src/gvfs_fuse.rs:
##
@@ -36,8 +36,8 @@ static SERVER: Lazy>>> = 
Lazy::new(|| Mutex::new(No
 pub(crate) enum CreateFileSystemResult {
 Memory(MemoryFileSystem),
 Gvfs(GravitinoFilesetFileSystem),
-FuseMemoryFs(FuseApiHandle>),
-FuseGvfs(FuseApiHandle>),
+FuseMemoryFs(FuseApiHandleDebug>),
+
FuseGvfs(FuseApiHandleDebug>),

Review Comment:
   Now, we can set `fuse_debug = true` at config file to enable debug logging.



##
clients/filesystem-fuse/src/fuse_api_handle_debug.rs:
##
@@ -0,0 +1,637 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+use crate::config::AppConfig;
+use crate::filesystem::{FileSystemContext, RawFileSystem};
+use crate::fuse_api_handle::FuseApiHandle;
+use chrono::DateTime;
+use fuse3::path::prelude::{ReplyData, ReplyOpen, ReplyStatFs, ReplyWrite};
+use fuse3::path::Request;
+use fuse3::raw::prelude::{
+FileAttr, ReplyAttr, ReplyCreated, ReplyDirectory, ReplyDirectoryPlus, 
ReplyEntry, ReplyInit,
+};
+use fuse3::raw::reply::{DirectoryEntry, DirectoryEntryPlus};
+use fuse3::raw::Filesystem;
+use fuse3::{Inode, SetAttr, Timestamp};
+use futures_util::stream::BoxStream;
+use std::ffi::OsStr;
+use std::fmt::Write;
+use tracing::{debug, error};
+
+/// Convert `ReplyAttr` to descriptive string.
+///
+/// Example: `ttl: 1s, FileAttr: { ino: 1, size: 0, blocks: 0, atime: 
"2025-01-10 12:12:29.452650", mtime: "2025-01-10 12:12:29.452650", ctime: 
"2025-01-10 12:12:29.452650", crtime: "2025-01-10 12:12:29.452650", kind: 
RegularFile, perm: 384, nlink: 1, uid: 501, gid: 20, rdev: 0, flags: 0, 
blksize: 8192 }`

Review Comment:
   Done.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]



Re: [PR] [#5873] feat(gvfs-fuse): add debug log for FuseApiHandle [gravitino]

2025-01-15 Thread via GitHub


unknowntpo commented on code in PR #5905:
URL: https://github.com/apache/gravitino/pull/5905#discussion_r1917598992


##
clients/filesystem-fuse/src/fuse_api_handle.rs:
##
@@ -117,6 +118,9 @@ impl Filesystem for FuseApiHandle {
 }
 
 let file_stat = self.fs.stat(inode).await?;
+
+debug!(req.unique, ?req, "filename" = ?file_stat.name, ?fh, "getattr 
started");
+

Review Comment:
   It's unnecessary, removed.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]



Re: [PR] [#5873] feat(gvfs-fuse): add debug log for FuseApiHandle [gravitino]

2025-01-15 Thread via GitHub


unknowntpo commented on code in PR #5905:
URL: https://github.com/apache/gravitino/pull/5905#discussion_r1917598465


##
clients/filesystem-fuse/src/gvfs_fuse.rs:
##
@@ -36,8 +36,8 @@ static SERVER: Lazy>>> = 
Lazy::new(|| Mutex::new(No
 pub(crate) enum CreateFileSystemResult {
 Memory(MemoryFileSystem),
 Gvfs(GravitinoFilesetFileSystem),
-FuseMemoryFs(FuseApiHandle>),
-FuseGvfs(FuseApiHandle>),
+FuseMemoryFs(FuseApiHandleDebug>),
+
FuseGvfs(FuseApiHandleDebug>),

Review Comment:
   Because this struct only log the debug message of methods in 
`FuseApiHandle`, so rename to `FuseLog` is a little bit ambiguous.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]



Re: [PR] [#5873] feat(gvfs-fuse): add debug log for FuseApiHandle [gravitino]

2025-01-15 Thread via GitHub


unknowntpo commented on code in PR #5905:
URL: https://github.com/apache/gravitino/pull/5905#discussion_r1917597636


##
clients/filesystem-fuse/src/fuse_api_handle_debug.rs:
##
@@ -0,0 +1,637 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+use crate::config::AppConfig;
+use crate::filesystem::{FileSystemContext, RawFileSystem};
+use crate::fuse_api_handle::FuseApiHandle;
+use chrono::DateTime;
+use fuse3::path::prelude::{ReplyData, ReplyOpen, ReplyStatFs, ReplyWrite};
+use fuse3::path::Request;
+use fuse3::raw::prelude::{
+FileAttr, ReplyAttr, ReplyCreated, ReplyDirectory, ReplyDirectoryPlus, 
ReplyEntry, ReplyInit,
+};
+use fuse3::raw::reply::{DirectoryEntry, DirectoryEntryPlus};
+use fuse3::raw::Filesystem;
+use fuse3::{Inode, SetAttr, Timestamp};
+use futures_util::stream::BoxStream;
+use std::ffi::OsStr;
+use std::fmt::Write;
+use tracing::{debug, error};
+
+/// Convert `ReplyAttr` to descriptive string.
+///
+/// Example: `ttl: 1s, FileAttr: { ino: 1, size: 0, blocks: 0, atime: 
"2025-01-10 12:12:29.452650", mtime: "2025-01-10 12:12:29.452650", ctime: 
"2025-01-10 12:12:29.452650", crtime: "2025-01-10 12:12:29.452650", kind: 
RegularFile, perm: 384, nlink: 1, uid: 501, gid: 20, rdev: 0, flags: 0, 
blksize: 8192 }`
+fn reply_attr_to_desc_str(reply_attr: &ReplyAttr) -> String {
+let mut output = String::new();
+
+write!(output, "ttl: {:?}, ", reply_attr.ttl).unwrap();
+write!(
+output,
+"FileAttr: {}",
+file_attr_to_desc_str(&reply_attr.attr)
+)
+.unwrap();
+
+output
+}
+
+/// Convert `ReplyEntry` to descriptive string.
+///
+/// Example: `ttl: 1s, FileAttr: { ino: 10001, size: 0, blocks: 1, atime: 
"2025-01-10 22:46:08.444791", mtime: "2025-01-10 22:46:08.444791", ctime: 
"2025-01-10 22:46:08.444791", crtime: "2025-01-10 22:46:08.444791", kind: 
Directory, perm: 448, nlink: 0, uid: 501, gid: 20, rdev: 0, flags: 0, blksize: 
8192 }, generation: 0`
+fn reply_entry_to_desc_str(reply_entry: &ReplyEntry) -> String {
+let mut output = String::new();
+
+write!(output, "ttl: {:?}, ", reply_entry.ttl).unwrap();
+write!(
+output,
+"FileAttr: {}, ",
+file_attr_to_desc_str(&reply_entry.attr)
+)
+.unwrap();
+write!(output, "generation: {}", reply_entry.generation).unwrap();
+
+output
+}
+
+/// Convert `ReplyCreated` to descriptive string.
+///
+/// Example: `ttl: 1s, FileAttr: { ino: 1, size: 0, blocks: 1, atime: 
"2025-01-10 22:53:45.491337", mtime: "2025-01-10 22:53:45.491337", ctime: 
"2025-01-10 22:53:45.491337", crtime: "2025-01-10 22:53:45.491337", kind: 
RegularFile, perm: 384, nlink: 0, uid: 501, gid: 20, rdev: 0, flags: 0, 
blksize: 8192 }, generation: 0, fh: 1`
+fn reply_created_to_desc_str(reply_created: &ReplyCreated) -> String {
+let mut output = String::new();
+
+write!(output, "ttl: {:?}, ", reply_created.ttl).unwrap();
+write!(
+output,
+"FileAttr: {}, ",
+file_attr_to_desc_str(&reply_created.attr)
+)
+.unwrap();
+write!(output, "generation: {}, ", reply_created.generation).unwrap();
+write!(output, "fh: {}", reply_created.fh).unwrap();
+
+output
+}
+
+/// Convert `FileAttr` to descriptive string.
+///
+/// Example: `{ ino: 1, size: 0, blocks: 0, atime: "2025-01-10 
12:12:29.452650", mtime: "2025-01-10 12:12:29.452650", ctime: "2025-01-10 
12:12:29.452650", crtime: "2025-01-10 12:12:29.452650", kind: RegularFile, 
perm: 384, nlink: 1, uid: 501, gid: 20, rdev: 0, flags: 0, blksize: 8192 }`
+fn file_attr_to_desc_str(attr: &FileAttr) -> String {
+let mut output = String::new();
+
+write!(output, "{{ ").unwrap();
+
+write!(output, "ino: {}, ", attr.ino).unwrap();
+write!(output, "size: {}, ", attr.size).unwrap();
+write!(output, "blocks: {}, ", attr.blocks).unwrap();
+write!(
+output,
+"atime: {:?}, ",
+timestamp_to_desc_string(attr.atime)
+)
+.unwrap();
+write!(
+output,
+"mtime: {:?}, ",
+timestamp_to_desc_string(attr.mtime)
+)
+.unwrap();
+write!(
+output,
+"ctime: {:?}, ",
+timestamp_to_desc_string(attr.ctime)
+)
+.unw

Re: [PR] [#5873] feat(gvfs-fuse): add debug log for FuseApiHandle [gravitino]

2025-01-12 Thread via GitHub


diqiu50 commented on code in PR #5905:
URL: https://github.com/apache/gravitino/pull/5905#discussion_r1912638515


##
clients/filesystem-fuse/src/gvfs_fuse.rs:
##
@@ -36,8 +36,8 @@ static SERVER: Lazy>>> = 
Lazy::new(|| Mutex::new(No
 pub(crate) enum CreateFileSystemResult {
 Memory(MemoryFileSystem),
 Gvfs(GravitinoFilesetFileSystem),
-FuseMemoryFs(FuseApiHandle>),
-FuseGvfs(FuseApiHandle>),
+FuseMemoryFs(FuseApiHandleDebug>),
+
FuseGvfs(FuseApiHandleDebug>),

Review Comment:
   Is it better to make the use of the DebugFuseApiHandle optional?



##
clients/filesystem-fuse/src/gvfs_fuse.rs:
##
@@ -36,8 +36,8 @@ static SERVER: Lazy>>> = 
Lazy::new(|| Mutex::new(No
 pub(crate) enum CreateFileSystemResult {
 Memory(MemoryFileSystem),
 Gvfs(GravitinoFilesetFileSystem),
-FuseMemoryFs(FuseApiHandle>),
-FuseGvfs(FuseApiHandle>),
+FuseMemoryFs(FuseApiHandleDebug>),
+
FuseGvfs(FuseApiHandleDebug>),

Review Comment:
   Is it better to use the name `FuseLog` instead of `FuseApiHandleDebug`?



##
clients/filesystem-fuse/src/fuse_api_handle_debug.rs:
##
@@ -0,0 +1,637 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+use crate::config::AppConfig;
+use crate::filesystem::{FileSystemContext, RawFileSystem};
+use crate::fuse_api_handle::FuseApiHandle;
+use chrono::DateTime;
+use fuse3::path::prelude::{ReplyData, ReplyOpen, ReplyStatFs, ReplyWrite};
+use fuse3::path::Request;
+use fuse3::raw::prelude::{
+FileAttr, ReplyAttr, ReplyCreated, ReplyDirectory, ReplyDirectoryPlus, 
ReplyEntry, ReplyInit,
+};
+use fuse3::raw::reply::{DirectoryEntry, DirectoryEntryPlus};
+use fuse3::raw::Filesystem;
+use fuse3::{Inode, SetAttr, Timestamp};
+use futures_util::stream::BoxStream;
+use std::ffi::OsStr;
+use std::fmt::Write;
+use tracing::{debug, error};
+
+/// Convert `ReplyAttr` to descriptive string.
+///
+/// Example: `ttl: 1s, FileAttr: { ino: 1, size: 0, blocks: 0, atime: 
"2025-01-10 12:12:29.452650", mtime: "2025-01-10 12:12:29.452650", ctime: 
"2025-01-10 12:12:29.452650", crtime: "2025-01-10 12:12:29.452650", kind: 
RegularFile, perm: 384, nlink: 1, uid: 501, gid: 20, rdev: 0, flags: 0, 
blksize: 8192 }`
+fn reply_attr_to_desc_str(reply_attr: &ReplyAttr) -> String {
+let mut output = String::new();
+
+write!(output, "ttl: {:?}, ", reply_attr.ttl).unwrap();
+write!(
+output,
+"FileAttr: {}",
+file_attr_to_desc_str(&reply_attr.attr)
+)
+.unwrap();
+
+output
+}
+
+/// Convert `ReplyEntry` to descriptive string.
+///
+/// Example: `ttl: 1s, FileAttr: { ino: 10001, size: 0, blocks: 1, atime: 
"2025-01-10 22:46:08.444791", mtime: "2025-01-10 22:46:08.444791", ctime: 
"2025-01-10 22:46:08.444791", crtime: "2025-01-10 22:46:08.444791", kind: 
Directory, perm: 448, nlink: 0, uid: 501, gid: 20, rdev: 0, flags: 0, blksize: 
8192 }, generation: 0`
+fn reply_entry_to_desc_str(reply_entry: &ReplyEntry) -> String {
+let mut output = String::new();
+
+write!(output, "ttl: {:?}, ", reply_entry.ttl).unwrap();
+write!(
+output,
+"FileAttr: {}, ",
+file_attr_to_desc_str(&reply_entry.attr)
+)
+.unwrap();
+write!(output, "generation: {}", reply_entry.generation).unwrap();
+
+output
+}
+
+/// Convert `ReplyCreated` to descriptive string.
+///
+/// Example: `ttl: 1s, FileAttr: { ino: 1, size: 0, blocks: 1, atime: 
"2025-01-10 22:53:45.491337", mtime: "2025-01-10 22:53:45.491337", ctime: 
"2025-01-10 22:53:45.491337", crtime: "2025-01-10 22:53:45.491337", kind: 
RegularFile, perm: 384, nlink: 0, uid: 501, gid: 20, rdev: 0, flags: 0, 
blksize: 8192 }, generation: 0, fh: 1`
+fn reply_created_to_desc_str(reply_created: &ReplyCreated) -> String {
+let mut output = String::new();
+
+write!(output, "ttl: {:?}, ", reply_created.ttl).unwrap();
+write!(
+output,
+"FileAttr: {}, ",
+file_attr_to_desc_str(&reply_created.attr)
+)
+.unwrap();
+write!(output, "generation: {}, ", reply_created.generation).unwrap();
+write!(output, "fh: {}", reply_created.fh).unwrap();
+
+output
+}
+
+/// Convert `FileAttr` to descriptive string.
+///
+///

Re: [PR] [#5873] feat(gvfs-fuse): add debug log for FuseApiHandle [gravitino]

2025-01-12 Thread via GitHub


diqiu50 commented on code in PR #5905:
URL: https://github.com/apache/gravitino/pull/5905#discussion_r1912627740


##
clients/filesystem-fuse/src/fuse_api_handle_debug.rs:
##
@@ -0,0 +1,637 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+use crate::config::AppConfig;
+use crate::filesystem::{FileSystemContext, RawFileSystem};
+use crate::fuse_api_handle::FuseApiHandle;
+use chrono::DateTime;
+use fuse3::path::prelude::{ReplyData, ReplyOpen, ReplyStatFs, ReplyWrite};
+use fuse3::path::Request;
+use fuse3::raw::prelude::{
+FileAttr, ReplyAttr, ReplyCreated, ReplyDirectory, ReplyDirectoryPlus, 
ReplyEntry, ReplyInit,
+};
+use fuse3::raw::reply::{DirectoryEntry, DirectoryEntryPlus};
+use fuse3::raw::Filesystem;
+use fuse3::{Inode, SetAttr, Timestamp};
+use futures_util::stream::BoxStream;
+use std::ffi::OsStr;
+use std::fmt::Write;
+use tracing::{debug, error};
+
+/// Convert `ReplyAttr` to descriptive string.
+///
+/// Example: `ttl: 1s, FileAttr: { ino: 1, size: 0, blocks: 0, atime: 
"2025-01-10 12:12:29.452650", mtime: "2025-01-10 12:12:29.452650", ctime: 
"2025-01-10 12:12:29.452650", crtime: "2025-01-10 12:12:29.452650", kind: 
RegularFile, perm: 384, nlink: 1, uid: 501, gid: 20, rdev: 0, flags: 0, 
blksize: 8192 }`

Review Comment:
   Can permissions be expressed in octal form?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]



Re: [PR] [#5873] feat(gvfs-fuse): add debug log for FuseApiHandle [gravitino]

2025-01-12 Thread via GitHub


diqiu50 commented on code in PR #5905:
URL: https://github.com/apache/gravitino/pull/5905#discussion_r1912623688


##
clients/filesystem-fuse/src/fuse_api_handle.rs:
##
@@ -117,6 +118,9 @@ impl Filesystem for FuseApiHandle {
 }
 
 let file_stat = self.fs.stat(inode).await?;
+
+debug!(req.unique, ?req, "filename" = ?file_stat.name, ?fh, "getattr 
started");
+

Review Comment:
   Why we add debug here?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]



Re: [PR] [#5873] feat(gvfs-fuse): add debug log for FuseApiHandle [gravitino]

2025-01-10 Thread via GitHub


unknowntpo commented on PR #5905:
URL: https://github.com/apache/gravitino/pull/5905#issuecomment-2584815279

   @diqiu50 Done, please take a look.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]



Re: [PR] [#5873] feat(gvfs-fuse): add debug log for FuseApiHandle [gravitino]

2025-01-10 Thread via GitHub


unknowntpo commented on code in PR #5905:
URL: https://github.com/apache/gravitino/pull/5905#discussion_r1911693611


##
clients/filesystem-fuse/src/fuse_api_handle.rs:
##
@@ -30,10 +30,474 @@ use fuse3::{Errno, FileType, Inode, SetAttr, Timestamp};
 use futures_util::stream;
 use futures_util::stream::BoxStream;
 use futures_util::StreamExt;
+use log::debug;
 use std::ffi::{OsStr, OsString};
+use std::fmt;
 use std::num::NonZeroU32;
 use std::time::{Duration, SystemTime};
 
+/// Wrapper Struct for `Timestamp` to enable custom Display implementation
+pub struct TimestampDebug(pub Timestamp);
+
+impl fmt::Display for TimestampDebug {
+fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
+let ts = &self.0; // Access the inner `Timestamp`
+write!(f, "{}.{:09}", ts.sec, ts.nsec) // Nanoseconds padded to 9 
digits
+}
+}
+
+// Optional Debug implementation for `TimestampDebug`
+impl fmt::Debug for TimestampDebug {
+fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
+write!(f, "Timestamp({})", self) // Reuses `Display` formatting
+}
+}
+
+pub struct FileAttrDebug<'a> {
+pub file_attr: &'a FileAttr,
+}
+
+impl<'a> std::fmt::Debug for FileAttrDebug<'a> {
+fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
+let attr = &self.file_attr;
+let mut struc = f.debug_struct("FileAttr");
+
+struc
+.field("ino", &attr.ino)
+.field("size", &attr.size)
+.field("blocks", &attr.blocks)
+.field("atime", &TimestampDebug(attr.atime))
+.field("mtime", &TimestampDebug(attr.mtime))
+.field("ctime", &TimestampDebug(attr.ctime));
+
+// Conditionally add the "crtime" field only for macOS
+#[cfg(target_os = "macos")]
+{
+struc.field("crtime", &TimestampDebug(attr.crtime));
+}
+
+struc
+.field("kind", &attr.kind)
+.field("perm", &attr.perm)
+.field("nlink", &attr.nlink)
+.field("uid", &attr.uid)
+.field("gid", &attr.gid)
+.field("rdev", &attr.rdev)
+.finish()
+}
+}
+
+pub(crate) struct FuseApiHandleDebug {
+inner: FuseApiHandle,
+}
+
+impl FuseApiHandleDebug {
+pub fn new(fs: T, context: FileSystemContext) -> Self {
+Self {
+inner: FuseApiHandle::new(fs, context),
+}
+}
+}
+
+impl Filesystem for FuseApiHandleDebug {
+async fn init(&self, req: Request) -> fuse3::Result {
+debug!("init [id={}]: req: {:?}", req.unique, req);
+let res = self.inner.init(req).await;
+match res {
+Ok(reply) => {
+debug!("init [id={}]: reply: {:?}", req.unique, reply);
+Ok(reply)
+}
+Err(e) => {
+debug!("init [id={}]: error: {:?}", req.unique, e);
+Err(e)
+}
+}
+}
+
+async fn destroy(&self, req: Request) {
+debug!("destroy [id={}]: req: {:?}", req.unique, req);
+self.inner.destroy(req).await;
+debug!("destroy [id={}]: completed", req.unique);
+}
+
+async fn lookup(&self, req: Request, parent: Inode, name: &OsStr) -> 
fuse3::Result {
+debug!(
+"lookup [id={}]: req: {:?}, parent: {:?}, name: {:?}",
+req.unique, req, parent, name
+);
+let result = self.inner.lookup(req, parent, name).await;
+match result {
+Ok(reply) => {
+debug!("lookup [id={}]: reply: {:?}", req.unique, reply);
+Ok(reply)
+}
+Err(e) => {
+debug!("lookup [id={}]: error: {:?}", req.unique, e);
+Err(e)
+}
+}
+}
+
+async fn getattr(
+&self,
+req: Request,
+inode: Inode,
+fh: Option,
+flags: u32,
+) -> fuse3::Result {
+debug!(
+"getattr [id={}]: req: {:?}, inode: {:?}, fh: {:?}, flags: {:?}",
+req.unique, req, inode, fh, flags
+);
+let result = self.inner.getattr(req, inode, fh, flags).await;
+match result {
+Ok(reply) => {
+debug!(
+"getattr [id={}]: reply: {:?}",
+req.unique,
+FileAttrDebug {
+file_attr: &reply.attr
+}
+);
+Ok(reply)
+}
+Err(e) => {
+debug!("getattr [id={}]: error: {:?}", req.unique, e);
+Err(e)
+}
+}
+}
+
+async fn setattr(
+&self,
+req: Request,
+inode: Inode,
+fh: Option,
+set_attr: SetAttr,
+) -> fuse3::Result {
+debug!(
+"setattr [id={}]: req: {:?}, inode: {:?}, fh: {:?}, set_attr: 
{:?}",
+req.unique, req, inode, fh, set_attr
+ 

Re: [PR] [#5873] feat(gvfs-fuse): add debug log for FuseApiHandle [gravitino]

2025-01-10 Thread via GitHub


unknowntpo commented on code in PR #5905:
URL: https://github.com/apache/gravitino/pull/5905#discussion_r1911692315


##
clients/filesystem-fuse/src/fuse_api_handle.rs:
##
@@ -30,10 +30,474 @@ use fuse3::{Errno, FileType, Inode, SetAttr, Timestamp};
 use futures_util::stream;
 use futures_util::stream::BoxStream;
 use futures_util::StreamExt;
+use log::debug;
 use std::ffi::{OsStr, OsString};
+use std::fmt;
 use std::num::NonZeroU32;
 use std::time::{Duration, SystemTime};
 
+/// Wrapper Struct for `Timestamp` to enable custom Display implementation
+pub struct TimestampDebug(pub Timestamp);
+
+impl fmt::Display for TimestampDebug {
+fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
+let ts = &self.0; // Access the inner `Timestamp`
+write!(f, "{}.{:09}", ts.sec, ts.nsec) // Nanoseconds padded to 9 
digits
+}
+}
+
+// Optional Debug implementation for `TimestampDebug`
+impl fmt::Debug for TimestampDebug {
+fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
+write!(f, "Timestamp({})", self) // Reuses `Display` formatting
+}
+}
+
+pub struct FileAttrDebug<'a> {
+pub file_attr: &'a FileAttr,
+}
+
+impl<'a> std::fmt::Debug for FileAttrDebug<'a> {
+fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
+let attr = &self.file_attr;
+let mut struc = f.debug_struct("FileAttr");
+
+struc
+.field("ino", &attr.ino)
+.field("size", &attr.size)
+.field("blocks", &attr.blocks)
+.field("atime", &TimestampDebug(attr.atime))
+.field("mtime", &TimestampDebug(attr.mtime))
+.field("ctime", &TimestampDebug(attr.ctime));
+
+// Conditionally add the "crtime" field only for macOS
+#[cfg(target_os = "macos")]
+{
+struc.field("crtime", &TimestampDebug(attr.crtime));
+}
+
+struc
+.field("kind", &attr.kind)
+.field("perm", &attr.perm)
+.field("nlink", &attr.nlink)
+.field("uid", &attr.uid)
+.field("gid", &attr.gid)
+.field("rdev", &attr.rdev)
+.finish()
+}
+}
+
+pub(crate) struct FuseApiHandleDebug {
+inner: FuseApiHandle,
+}
+
+impl FuseApiHandleDebug {
+pub fn new(fs: T, context: FileSystemContext) -> Self {
+Self {
+inner: FuseApiHandle::new(fs, context),
+}
+}
+}
+
+impl Filesystem for FuseApiHandleDebug {
+async fn init(&self, req: Request) -> fuse3::Result {
+debug!("init [id={}]: req: {:?}", req.unique, req);
+let res = self.inner.init(req).await;
+match res {
+Ok(reply) => {
+debug!("init [id={}]: reply: {:?}", req.unique, reply);
+Ok(reply)
+}
+Err(e) => {
+debug!("init [id={}]: error: {:?}", req.unique, e);
+Err(e)

Review Comment:
   Yeah, `error!` is better, fixed.



##
clients/filesystem-fuse/src/fuse_api_handle.rs:
##
@@ -30,10 +30,474 @@ use fuse3::{Errno, FileType, Inode, SetAttr, Timestamp};
 use futures_util::stream;
 use futures_util::stream::BoxStream;
 use futures_util::StreamExt;
+use log::debug;
 use std::ffi::{OsStr, OsString};
+use std::fmt;
 use std::num::NonZeroU32;
 use std::time::{Duration, SystemTime};
 
+/// Wrapper Struct for `Timestamp` to enable custom Display implementation
+pub struct TimestampDebug(pub Timestamp);
+
+impl fmt::Display for TimestampDebug {
+fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
+let ts = &self.0; // Access the inner `Timestamp`
+write!(f, "{}.{:09}", ts.sec, ts.nsec) // Nanoseconds padded to 9 
digits
+}
+}
+
+// Optional Debug implementation for `TimestampDebug`
+impl fmt::Debug for TimestampDebug {
+fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
+write!(f, "Timestamp({})", self) // Reuses `Display` formatting
+}
+}
+
+pub struct FileAttrDebug<'a> {
+pub file_attr: &'a FileAttr,
+}
+
+impl<'a> std::fmt::Debug for FileAttrDebug<'a> {
+fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
+let attr = &self.file_attr;
+let mut struc = f.debug_struct("FileAttr");
+
+struc
+.field("ino", &attr.ino)
+.field("size", &attr.size)
+.field("blocks", &attr.blocks)
+.field("atime", &TimestampDebug(attr.atime))
+.field("mtime", &TimestampDebug(attr.mtime))
+.field("ctime", &TimestampDebug(attr.ctime));
+
+// Conditionally add the "crtime" field only for macOS
+#[cfg(target_os = "macos")]
+{
+struc.field("crtime", &TimestampDebug(attr.crtime));
+}
+
+struc
+.field("kind", &attr.kind)
+.field("perm", &attr.perm)
+.field("nlink", &attr.nlink)
+.field("uid", &attr.uid)
+.field("gid", &attr.gi

Re: [PR] [#5873] feat(gvfs-fuse): add debug log for FuseApiHandle [gravitino]

2025-01-10 Thread via GitHub


unknowntpo commented on code in PR #5905:
URL: https://github.com/apache/gravitino/pull/5905#discussion_r1911690746


##
clients/filesystem-fuse/src/fuse_api_handle.rs:
##
@@ -30,10 +30,474 @@ use fuse3::{Errno, FileType, Inode, SetAttr, Timestamp};
 use futures_util::stream;
 use futures_util::stream::BoxStream;
 use futures_util::StreamExt;
+use log::debug;
 use std::ffi::{OsStr, OsString};
+use std::fmt;
 use std::num::NonZeroU32;
 use std::time::{Duration, SystemTime};
 
+/// Wrapper Struct for `Timestamp` to enable custom Display implementation
+pub struct TimestampDebug(pub Timestamp);
+
+impl fmt::Display for TimestampDebug {
+fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
+let ts = &self.0; // Access the inner `Timestamp`
+write!(f, "{}.{:09}", ts.sec, ts.nsec) // Nanoseconds padded to 9 
digits

Review Comment:
   I implemented some methods like `reply_attr_to_desc_str`, 
`reply_entry_to_desc_str` to manually control the format.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]



Re: [PR] [#5873] feat(gvfs-fuse): add debug log for FuseApiHandle [gravitino]

2025-01-10 Thread via GitHub


unknowntpo commented on code in PR #5905:
URL: https://github.com/apache/gravitino/pull/5905#discussion_r1911688931


##
clients/filesystem-fuse/src/fuse_api_handle.rs:
##
@@ -30,10 +30,174 @@ use fuse3::{Errno, FileType, Inode, SetAttr, Timestamp};
 use futures_util::stream;
 use futures_util::stream::BoxStream;
 use futures_util::StreamExt;
+use log::debug;
 use std::ffi::{OsStr, OsString};
 use std::num::NonZeroU32;
 use std::time::{Duration, SystemTime};
 
+pub(crate) struct FuseApiHandleDebug {
+inner: FuseApiHandle,
+}
+
+impl FuseApiHandleDebug {
+pub fn new(fs: T, context: FileSystemContext) -> Self {
+Self {
+inner: FuseApiHandle::new(fs, context),
+}
+}
+
+pub async fn get_file_path(&self, file_id: u64) -> String {
+debug!("get_file_path: file_id: {}", file_id);
+let result = self.inner.get_file_path(file_id).await;
+debug!("get_file_path result: {}", result);
+result
+}
+
+async fn get_modified_file_stat(
+&self,
+file_id: u64,
+size: Option,
+atime: Option,
+mtime: Option,
+) -> Result {
+debug!("get_modified_file_stat: file_id: {}, size: {:?}, atime: {:?}, 
mtime: {:?}", file_id, size, atime, mtime);

Review Comment:
   I implemented some methods like `reply_attr_to_desc_str`, 
`reply_entry_to_desc_str` to manually control the format.



##
clients/filesystem-fuse/src/fuse_api_handle.rs:
##
@@ -30,10 +30,474 @@ use fuse3::{Errno, FileType, Inode, SetAttr, Timestamp};
 use futures_util::stream;
 use futures_util::stream::BoxStream;
 use futures_util::StreamExt;
+use log::debug;
 use std::ffi::{OsStr, OsString};
+use std::fmt;
 use std::num::NonZeroU32;
 use std::time::{Duration, SystemTime};
 
+/// Wrapper Struct for `Timestamp` to enable custom Display implementation
+pub struct TimestampDebug(pub Timestamp);
+
+impl fmt::Display for TimestampDebug {
+fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
+let ts = &self.0; // Access the inner `Timestamp`
+write!(f, "{}.{:09}", ts.sec, ts.nsec) // Nanoseconds padded to 9 
digits
+}
+}
+
+// Optional Debug implementation for `TimestampDebug`
+impl fmt::Debug for TimestampDebug {
+fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
+write!(f, "Timestamp({})", self) // Reuses `Display` formatting
+}
+}
+
+pub struct FileAttrDebug<'a> {
+pub file_attr: &'a FileAttr,
+}
+
+impl<'a> std::fmt::Debug for FileAttrDebug<'a> {
+fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
+let attr = &self.file_attr;
+let mut struc = f.debug_struct("FileAttr");
+
+struc
+.field("ino", &attr.ino)
+.field("size", &attr.size)
+.field("blocks", &attr.blocks)
+.field("atime", &TimestampDebug(attr.atime))
+.field("mtime", &TimestampDebug(attr.mtime))
+.field("ctime", &TimestampDebug(attr.ctime));
+
+// Conditionally add the "crtime" field only for macOS
+#[cfg(target_os = "macos")]
+{
+struc.field("crtime", &TimestampDebug(attr.crtime));
+}
+
+struc
+.field("kind", &attr.kind)
+.field("perm", &attr.perm)
+.field("nlink", &attr.nlink)
+.field("uid", &attr.uid)
+.field("gid", &attr.gid)
+.field("rdev", &attr.rdev)
+.finish()
+}
+}
+
+pub(crate) struct FuseApiHandleDebug {
+inner: FuseApiHandle,
+}
+
+impl FuseApiHandleDebug {
+pub fn new(fs: T, context: FileSystemContext) -> Self {
+Self {
+inner: FuseApiHandle::new(fs, context),
+}
+}
+}
+
+impl Filesystem for FuseApiHandleDebug {
+async fn init(&self, req: Request) -> fuse3::Result {
+debug!("init [id={}]: req: {:?}", req.unique, req);
+let res = self.inner.init(req).await;
+match res {
+Ok(reply) => {
+debug!("init [id={}]: reply: {:?}", req.unique, reply);
+Ok(reply)
+}
+Err(e) => {
+debug!("init [id={}]: error: {:?}", req.unique, e);
+Err(e)
+}
+}
+}
+
+async fn destroy(&self, req: Request) {
+debug!("destroy [id={}]: req: {:?}", req.unique, req);
+self.inner.destroy(req).await;
+debug!("destroy [id={}]: completed", req.unique);
+}
+
+async fn lookup(&self, req: Request, parent: Inode, name: &OsStr) -> 
fuse3::Result {
+debug!(
+"lookup [id={}]: req: {:?}, parent: {:?}, name: {:?}",
+req.unique, req, parent, name
+);
+let result = self.inner.lookup(req, parent, name).await;
+match result {
+Ok(reply) => {
+debug!("lookup [id={}]: reply: {:?}", req.unique, reply);
+Ok(reply)
+}
+Err(e) => {
+

Re: [PR] [#5873] feat(gvfs-fuse): add debug log for FuseApiHandle [gravitino]

2025-01-10 Thread via GitHub


unknowntpo commented on code in PR #5905:
URL: https://github.com/apache/gravitino/pull/5905#discussion_r1911688931


##
clients/filesystem-fuse/src/fuse_api_handle.rs:
##
@@ -30,10 +30,174 @@ use fuse3::{Errno, FileType, Inode, SetAttr, Timestamp};
 use futures_util::stream;
 use futures_util::stream::BoxStream;
 use futures_util::StreamExt;
+use log::debug;
 use std::ffi::{OsStr, OsString};
 use std::num::NonZeroU32;
 use std::time::{Duration, SystemTime};
 
+pub(crate) struct FuseApiHandleDebug {
+inner: FuseApiHandle,
+}
+
+impl FuseApiHandleDebug {
+pub fn new(fs: T, context: FileSystemContext) -> Self {
+Self {
+inner: FuseApiHandle::new(fs, context),
+}
+}
+
+pub async fn get_file_path(&self, file_id: u64) -> String {
+debug!("get_file_path: file_id: {}", file_id);
+let result = self.inner.get_file_path(file_id).await;
+debug!("get_file_path result: {}", result);
+result
+}
+
+async fn get_modified_file_stat(
+&self,
+file_id: u64,
+size: Option,
+atime: Option,
+mtime: Option,
+) -> Result {
+debug!("get_modified_file_stat: file_id: {}, size: {:?}, atime: {:?}, 
mtime: {:?}", file_id, size, atime, mtime);

Review Comment:
   I implement some methods like `reply_attr_to_desc_str`, 
`reply_entry_to_desc_str` to manually control the format.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]



Re: [PR] [#5873] feat(gvfs-fuse): add debug log for FuseApiHandle [gravitino]

2025-01-10 Thread via GitHub


unknowntpo commented on PR #5905:
URL: https://github.com/apache/gravitino/pull/5905#issuecomment-2584803594

   Note that I use `tracing::debug`, `tracing::error` with structure logging to 
format the message in key value pair format, so we don't need to control format 
manually.
   
   e.g.
   
   debug!(req.unique, ?req, parent = ?parent_stat.name, ?name, "lookup 
started");


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]



Re: [PR] [#5873] feat(gvfs-fuse): add debug log for FuseApiHandle [gravitino]

2025-01-09 Thread via GitHub


unknowntpo commented on PR #5905:
URL: https://github.com/apache/gravitino/pull/5905#issuecomment-2581610514

   @diqiu50 Should I also format the `Timestamp` in the reply structure ? This 
will take lots of efforts because we need to implement to formatting function 
for `ReplyAttr`, `ReplyEntry`, `ReplyCreated`.
   
   
https://github.com/apache/gravitino/pull/5905/files#diff-40eea995574e00f655537ad77f0dd386ef8a4fd8a3eb9ca791f61bd43a76294eR178


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]



Re: [PR] [#5873] feat(gvfs-fuse): add debug log for FuseApiHandle [gravitino]

2025-01-05 Thread via GitHub


unknowntpo commented on PR #5905:
URL: https://github.com/apache/gravitino/pull/5905#issuecomment-2572196668

   @diqiu50 Okay, (I'm still working this PR)


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]



Re: [PR] [#5873] feat(gvfs-fuse): add debug log for FuseApiHandle [gravitino]

2025-01-05 Thread via GitHub


diqiu50 commented on PR #5905:
URL: https://github.com/apache/gravitino/pull/5905#issuecomment-2572194500

   @unknowntpo All the code are merged to the main brach.  you need to merge 
the pr to main


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]



Re: [PR] [#5873] feat(gvfs-fuse): add debug log for FuseApiHandle [gravitino]

2024-12-29 Thread via GitHub


diqiu50 commented on code in PR #5905:
URL: https://github.com/apache/gravitino/pull/5905#discussion_r1899328179


##
clients/filesystem-fuse/src/fuse_api_handle.rs:
##
@@ -30,10 +30,474 @@ use fuse3::{Errno, FileType, Inode, SetAttr, Timestamp};
 use futures_util::stream;
 use futures_util::stream::BoxStream;
 use futures_util::StreamExt;
+use log::debug;
 use std::ffi::{OsStr, OsString};
+use std::fmt;
 use std::num::NonZeroU32;
 use std::time::{Duration, SystemTime};
 
+/// Wrapper Struct for `Timestamp` to enable custom Display implementation
+pub struct TimestampDebug(pub Timestamp);
+
+impl fmt::Display for TimestampDebug {
+fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
+let ts = &self.0; // Access the inner `Timestamp`
+write!(f, "{}.{:09}", ts.sec, ts.nsec) // Nanoseconds padded to 9 
digits
+}
+}
+
+// Optional Debug implementation for `TimestampDebug`
+impl fmt::Debug for TimestampDebug {
+fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
+write!(f, "Timestamp({})", self) // Reuses `Display` formatting
+}
+}
+
+pub struct FileAttrDebug<'a> {
+pub file_attr: &'a FileAttr,
+}
+
+impl<'a> std::fmt::Debug for FileAttrDebug<'a> {
+fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
+let attr = &self.file_attr;
+let mut struc = f.debug_struct("FileAttr");
+
+struc
+.field("ino", &attr.ino)
+.field("size", &attr.size)
+.field("blocks", &attr.blocks)
+.field("atime", &TimestampDebug(attr.atime))
+.field("mtime", &TimestampDebug(attr.mtime))
+.field("ctime", &TimestampDebug(attr.ctime));
+
+// Conditionally add the "crtime" field only for macOS
+#[cfg(target_os = "macos")]
+{
+struc.field("crtime", &TimestampDebug(attr.crtime));
+}
+
+struc
+.field("kind", &attr.kind)
+.field("perm", &attr.perm)
+.field("nlink", &attr.nlink)
+.field("uid", &attr.uid)
+.field("gid", &attr.gid)
+.field("rdev", &attr.rdev)
+.finish()
+}
+}
+
+pub(crate) struct FuseApiHandleDebug {
+inner: FuseApiHandle,
+}
+
+impl FuseApiHandleDebug {
+pub fn new(fs: T, context: FileSystemContext) -> Self {
+Self {
+inner: FuseApiHandle::new(fs, context),
+}
+}
+}
+
+impl Filesystem for FuseApiHandleDebug {
+async fn init(&self, req: Request) -> fuse3::Result {
+debug!("init [id={}]: req: {:?}", req.unique, req);
+let res = self.inner.init(req).await;
+match res {
+Ok(reply) => {
+debug!("init [id={}]: reply: {:?}", req.unique, reply);
+Ok(reply)
+}
+Err(e) => {
+debug!("init [id={}]: error: {:?}", req.unique, e);
+Err(e)
+}
+}
+}
+
+async fn destroy(&self, req: Request) {
+debug!("destroy [id={}]: req: {:?}", req.unique, req);
+self.inner.destroy(req).await;
+debug!("destroy [id={}]: completed", req.unique);
+}
+
+async fn lookup(&self, req: Request, parent: Inode, name: &OsStr) -> 
fuse3::Result {
+debug!(
+"lookup [id={}]: req: {:?}, parent: {:?}, name: {:?}",
+req.unique, req, parent, name
+);
+let result = self.inner.lookup(req, parent, name).await;
+match result {
+Ok(reply) => {
+debug!("lookup [id={}]: reply: {:?}", req.unique, reply);
+Ok(reply)
+}
+Err(e) => {
+debug!("lookup [id={}]: error: {:?}", req.unique, e);
+Err(e)
+}
+}
+}
+
+async fn getattr(
+&self,
+req: Request,
+inode: Inode,
+fh: Option,
+flags: u32,
+) -> fuse3::Result {
+debug!(
+"getattr [id={}]: req: {:?}, inode: {:?}, fh: {:?}, flags: {:?}",
+req.unique, req, inode, fh, flags
+);
+let result = self.inner.getattr(req, inode, fh, flags).await;
+match result {
+Ok(reply) => {
+debug!(
+"getattr [id={}]: reply: {:?}",
+req.unique,
+FileAttrDebug {
+file_attr: &reply.attr
+}
+);
+Ok(reply)
+}
+Err(e) => {
+debug!("getattr [id={}]: error: {:?}", req.unique, e);
+Err(e)
+}
+}
+}
+
+async fn setattr(
+&self,
+req: Request,
+inode: Inode,
+fh: Option,
+set_attr: SetAttr,
+) -> fuse3::Result {
+debug!(
+"setattr [id={}]: req: {:?}, inode: {:?}, fh: {:?}, set_attr: 
{:?}",
+req.unique, req, inode, fh, set_attr
+

Re: [PR] [#5873] feat(gvfs-fuse): add debug log for FuseApiHandle [gravitino]

2024-12-29 Thread via GitHub


diqiu50 commented on code in PR #5905:
URL: https://github.com/apache/gravitino/pull/5905#discussion_r1899327474


##
clients/filesystem-fuse/src/fuse_api_handle.rs:
##
@@ -30,10 +30,474 @@ use fuse3::{Errno, FileType, Inode, SetAttr, Timestamp};
 use futures_util::stream;
 use futures_util::stream::BoxStream;
 use futures_util::StreamExt;
+use log::debug;
 use std::ffi::{OsStr, OsString};
+use std::fmt;
 use std::num::NonZeroU32;
 use std::time::{Duration, SystemTime};
 
+/// Wrapper Struct for `Timestamp` to enable custom Display implementation
+pub struct TimestampDebug(pub Timestamp);
+
+impl fmt::Display for TimestampDebug {
+fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
+let ts = &self.0; // Access the inner `Timestamp`
+write!(f, "{}.{:09}", ts.sec, ts.nsec) // Nanoseconds padded to 9 
digits
+}
+}
+
+// Optional Debug implementation for `TimestampDebug`
+impl fmt::Debug for TimestampDebug {
+fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
+write!(f, "Timestamp({})", self) // Reuses `Display` formatting
+}
+}
+
+pub struct FileAttrDebug<'a> {
+pub file_attr: &'a FileAttr,
+}
+
+impl<'a> std::fmt::Debug for FileAttrDebug<'a> {
+fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
+let attr = &self.file_attr;
+let mut struc = f.debug_struct("FileAttr");
+
+struc
+.field("ino", &attr.ino)
+.field("size", &attr.size)
+.field("blocks", &attr.blocks)
+.field("atime", &TimestampDebug(attr.atime))
+.field("mtime", &TimestampDebug(attr.mtime))
+.field("ctime", &TimestampDebug(attr.ctime));
+
+// Conditionally add the "crtime" field only for macOS
+#[cfg(target_os = "macos")]
+{
+struc.field("crtime", &TimestampDebug(attr.crtime));
+}
+
+struc
+.field("kind", &attr.kind)
+.field("perm", &attr.perm)
+.field("nlink", &attr.nlink)
+.field("uid", &attr.uid)
+.field("gid", &attr.gid)
+.field("rdev", &attr.rdev)
+.finish()
+}
+}
+
+pub(crate) struct FuseApiHandleDebug {
+inner: FuseApiHandle,
+}
+
+impl FuseApiHandleDebug {
+pub fn new(fs: T, context: FileSystemContext) -> Self {
+Self {
+inner: FuseApiHandle::new(fs, context),
+}
+}
+}
+
+impl Filesystem for FuseApiHandleDebug {
+async fn init(&self, req: Request) -> fuse3::Result {
+debug!("init [id={}]: req: {:?}", req.unique, req);
+let res = self.inner.init(req).await;
+match res {
+Ok(reply) => {
+debug!("init [id={}]: reply: {:?}", req.unique, reply);
+Ok(reply)
+}
+Err(e) => {
+debug!("init [id={}]: error: {:?}", req.unique, e);
+Err(e)
+}
+}
+}
+
+async fn destroy(&self, req: Request) {
+debug!("destroy [id={}]: req: {:?}", req.unique, req);
+self.inner.destroy(req).await;
+debug!("destroy [id={}]: completed", req.unique);
+}
+
+async fn lookup(&self, req: Request, parent: Inode, name: &OsStr) -> 
fuse3::Result {
+debug!(
+"lookup [id={}]: req: {:?}, parent: {:?}, name: {:?}",
+req.unique, req, parent, name
+);
+let result = self.inner.lookup(req, parent, name).await;
+match result {
+Ok(reply) => {
+debug!("lookup [id={}]: reply: {:?}", req.unique, reply);
+Ok(reply)
+}
+Err(e) => {
+debug!("lookup [id={}]: error: {:?}", req.unique, e);
+Err(e)
+}
+}
+}
+
+async fn getattr(
+&self,
+req: Request,
+inode: Inode,
+fh: Option,
+flags: u32,
+) -> fuse3::Result {
+debug!(
+"getattr [id={}]: req: {:?}, inode: {:?}, fh: {:?}, flags: {:?}",
+req.unique, req, inode, fh, flags
+);
+let result = self.inner.getattr(req, inode, fh, flags).await;
+match result {
+Ok(reply) => {
+debug!(
+"getattr [id={}]: reply: {:?}",
+req.unique,
+FileAttrDebug {
+file_attr: &reply.attr
+}
+);
+Ok(reply)
+}
+Err(e) => {
+debug!("getattr [id={}]: error: {:?}", req.unique, e);
+Err(e)
+}
+}
+}
+
+async fn setattr(
+&self,
+req: Request,
+inode: Inode,
+fh: Option,
+set_attr: SetAttr,
+) -> fuse3::Result {
+debug!(
+"setattr [id={}]: req: {:?}, inode: {:?}, fh: {:?}, set_attr: 
{:?}",
+req.unique, req, inode, fh, set_attr
+

Re: [PR] [#5873] feat(gvfs-fuse): add debug log for FuseApiHandle [gravitino]

2024-12-29 Thread via GitHub


diqiu50 commented on code in PR #5905:
URL: https://github.com/apache/gravitino/pull/5905#discussion_r1899326821


##
clients/filesystem-fuse/src/fuse_api_handle.rs:
##
@@ -30,10 +30,474 @@ use fuse3::{Errno, FileType, Inode, SetAttr, Timestamp};
 use futures_util::stream;
 use futures_util::stream::BoxStream;
 use futures_util::StreamExt;
+use log::debug;
 use std::ffi::{OsStr, OsString};
+use std::fmt;
 use std::num::NonZeroU32;
 use std::time::{Duration, SystemTime};
 
+/// Wrapper Struct for `Timestamp` to enable custom Display implementation
+pub struct TimestampDebug(pub Timestamp);
+
+impl fmt::Display for TimestampDebug {
+fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
+let ts = &self.0; // Access the inner `Timestamp`
+write!(f, "{}.{:09}", ts.sec, ts.nsec) // Nanoseconds padded to 9 
digits
+}
+}
+
+// Optional Debug implementation for `TimestampDebug`
+impl fmt::Debug for TimestampDebug {
+fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
+write!(f, "Timestamp({})", self) // Reuses `Display` formatting
+}
+}
+
+pub struct FileAttrDebug<'a> {
+pub file_attr: &'a FileAttr,
+}
+
+impl<'a> std::fmt::Debug for FileAttrDebug<'a> {
+fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
+let attr = &self.file_attr;
+let mut struc = f.debug_struct("FileAttr");
+
+struc
+.field("ino", &attr.ino)
+.field("size", &attr.size)
+.field("blocks", &attr.blocks)
+.field("atime", &TimestampDebug(attr.atime))
+.field("mtime", &TimestampDebug(attr.mtime))
+.field("ctime", &TimestampDebug(attr.ctime));
+
+// Conditionally add the "crtime" field only for macOS
+#[cfg(target_os = "macos")]
+{
+struc.field("crtime", &TimestampDebug(attr.crtime));
+}
+
+struc
+.field("kind", &attr.kind)
+.field("perm", &attr.perm)
+.field("nlink", &attr.nlink)
+.field("uid", &attr.uid)
+.field("gid", &attr.gid)
+.field("rdev", &attr.rdev)
+.finish()
+}
+}
+
+pub(crate) struct FuseApiHandleDebug {
+inner: FuseApiHandle,
+}
+
+impl FuseApiHandleDebug {
+pub fn new(fs: T, context: FileSystemContext) -> Self {
+Self {
+inner: FuseApiHandle::new(fs, context),
+}
+}
+}
+
+impl Filesystem for FuseApiHandleDebug {
+async fn init(&self, req: Request) -> fuse3::Result {
+debug!("init [id={}]: req: {:?}", req.unique, req);
+let res = self.inner.init(req).await;
+match res {
+Ok(reply) => {
+debug!("init [id={}]: reply: {:?}", req.unique, reply);
+Ok(reply)
+}
+Err(e) => {
+debug!("init [id={}]: error: {:?}", req.unique, e);
+Err(e)
+}
+}
+}
+
+async fn destroy(&self, req: Request) {
+debug!("destroy [id={}]: req: {:?}", req.unique, req);
+self.inner.destroy(req).await;
+debug!("destroy [id={}]: completed", req.unique);
+}
+
+async fn lookup(&self, req: Request, parent: Inode, name: &OsStr) -> 
fuse3::Result {
+debug!(
+"lookup [id={}]: req: {:?}, parent: {:?}, name: {:?}",
+req.unique, req, parent, name
+);
+let result = self.inner.lookup(req, parent, name).await;
+match result {
+Ok(reply) => {
+debug!("lookup [id={}]: reply: {:?}", req.unique, reply);
+Ok(reply)
+}
+Err(e) => {
+debug!("lookup [id={}]: error: {:?}", req.unique, e);
+Err(e)
+}
+}
+}
+
+async fn getattr(
+&self,
+req: Request,
+inode: Inode,
+fh: Option,
+flags: u32,
+) -> fuse3::Result {
+debug!(
+"getattr [id={}]: req: {:?}, inode: {:?}, fh: {:?}, flags: {:?}",
+req.unique, req, inode, fh, flags
+);
+let result = self.inner.getattr(req, inode, fh, flags).await;
+match result {
+Ok(reply) => {
+debug!(
+"getattr [id={}]: reply: {:?}",
+req.unique,
+FileAttrDebug {
+file_attr: &reply.attr
+}

Review Comment:
   Constructing an object is not as clear as using  a function like 
`to_desc_string()`



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]



  1   2   >