Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Added logging to src/pelicanfs/core.py #69

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

turetske
Copy link
Collaborator

close #58

Copy link
Member

@jhiemstrawisc jhiemstrawisc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Most of the new debug statements seem a bit brief/terse, and some only really log the name of the function they're in. For instance, the two messages in _check_fspath() are currently "Checking path: {path}" and "Compatible path: {path}." If these log statements are primarily intended for developers, they provide enough information to locate sections in the codebase via grep. However, if they are also meant to assist non-technical users or provide more context in logs, they might benefit from being more descriptive. For example, "Checking path {path} for compatibility with blah blah blah" would add clarity on what's being checked and why.

if fileloc[0] == "/":
fileloc = fileloc[1:]

if not self.directorUrl:
logger.debug("Director URL not set, geting from disocyr url")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

disocyr --> discovery

@@ -220,6 +223,7 @@ async def get_director_headers(self, fileloc, origin=False) -> dict[str, str]:
directorUrl = directorUrl + "/"
self.directorUrl = directorUrl

logger.debug(f"Getting headers from director: {self.directorUrl}")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This debug message gets printed twice with different phrasing

@@ -232,15 +236,18 @@ async def get_working_cache(self, fileloc: str) -> str:
"""
Returns the highest priority cache for the namespace that appears to be working
"""
logger.debug(f"Get a working cache for {fileloc}")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The verbiage here feels wrong. Maybe "choosing a cache for ..."?

return cacheUrl

# Calculate the list of applicable caches; this takes into account the
# preferredCaches for the filesystem. If '+' is a preferred cache, we
# add all the director-provided caches to the list (doing a round of de-dup)
logger.debug("Getting a cache from the director")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This one is also logged twice

session.headers["Authorization"] = self.token
try:
logger.debug(f"Testing cacheurl {updatedUrl}")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cacheurl --> cache url

It might also be nice to include some information about what's being tested, e.g. f"testing cache {updatedUrl} for blah blah blah"

namespace_info = self._get_prefix_info(fileloc)
if not namespace_info:
return


logger.debug(f"Match found")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can also log the match here

@@ -342,10 +353,12 @@ def _get_prefix_info(self, path: str) -> _CacheManager:
return namespace_info

def _match_namespace(self, fileloc: str):
logger.debug(f"Matching namespace for {fileloc}")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe "Extracting namespace prefix from object {fileloc}"? I don't find "match" very descriptive of what's going on here

@@ -535,6 +555,7 @@ async def open_async(self, path, **kwargs):
data_url = await self.get_origin_url(path)
else:
data_url = self.get_working_cache(path)
logger.debug(f"Running open_aync on {data_url}")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

open_aync --> open_async

@@ -511,6 +528,7 @@ def _check_fspath(self, path: str) -> str:
check that the pelican://-style URL is compatible with the current
filesystem object and return the path.
"""
logger.debug(f"Checking path: {path}")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will someone seeing this in a log know what "checking path" means? Or is it worth being more verbose about what's being checked?

@@ -402,6 +417,7 @@ async def _glob(self, path, maxdepth=None, **kwargs):
except it cleans the path url of double '//' and checks for
the dirlisthost ahead of time
"""
logger.debug("Starting glob...")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the only spot you use an ellipsis in these types of debug statements. I actually like this -- to me it signifies the beginning of some multi-step process. Either way, can you pick one or the other and use it throughout?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add logging support to enable debugging
2 participants