Skip to content

Commit 17177b2

Browse files
ctothclaude
andcommitted
fix: Improve logging levels and add COM module logging
- Change verbose implementation details from INFO to DEBUG level - Add proper logging to COM module with error context - Remove duplicate path logging in find_library_path - Keep essential INFO messages for successful library loads 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
1 parent 3726067 commit 17177b2

File tree

2 files changed

+17
-6
lines changed

2 files changed

+17
-6
lines changed

libloader/com.py

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,34 @@
1+
import logging
12
from pywintypes import com_error
23
from win32com.client import gencache
34

5+
# Set up logger
6+
logger = logging.getLogger(__name__)
7+
48

59
def prepare_gencache():
10+
logger.debug("Preparing gencache for COM object loading")
611
gencache.is_readonly = False
712
gencache.GetGeneratePath()
813

914

1015
def load_com(*names):
16+
logger.debug("Attempting to load COM objects: %s", names)
1117
if gencache.is_readonly:
1218
prepare_gencache()
1319
result = None
20+
failed_names = []
1421
for name in names:
1522
try:
23+
logger.debug("Trying to load COM object: %s", name)
1624
result = gencache.EnsureDispatch(name)
25+
logger.info("Successfully loaded COM object: %s", name)
1726
break
18-
except com_error:
27+
except com_error as e:
28+
logger.debug("Failed to load COM object %s: %s", name, str(e))
29+
failed_names.append(name)
1930
continue
2031
if result is None:
21-
raise com_error("Unable to load any of the provided com objects.")
32+
logger.error("Failed to load any COM objects. Tried: %s", failed_names)
33+
raise com_error("Unable to load any of the provided com objects: %s" % failed_names)
2234
return result

libloader/libloader.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,15 +37,15 @@ class LibraryLoadError(OSError):
3737

3838

3939
def load_library(library, x86_path=".", x64_path=".", *args, **kwargs):
40-
logger.info("Attempting to load library: %s", library)
40+
logger.debug("Attempting to load library: %s", library)
4141
logger.debug("x86_path: %s, x64_path: %s", os.path.abspath(x86_path), os.path.abspath(x64_path))
4242

4343
lib = find_library_path(library, x86_path=x86_path, x64_path=x64_path)
44-
logger.info("Resolved library path: %s", lib)
44+
logger.debug("Resolved library path: %s", lib)
4545

4646
loaded = _do_load(lib, *args, **kwargs)
4747
if loaded is not None:
48-
logger.info("Successfully loaded library: %s", lib)
48+
logger.info("Successfully loaded library: %s", os.path.basename(lib))
4949
return loaded
5050

5151
logger.error("Failed to load library: %s", lib)
@@ -87,7 +87,6 @@ def find_library_path(libname, x86_path=".", x64_path="."):
8787
path = "%s%s" % (path, ext)
8888
abs_path = os.path.abspath(path)
8989

90-
logger.info("Resolved library path: %s", abs_path)
9190
logger.debug("Path exists: %s", os.path.exists(abs_path))
9291

9392
return abs_path

0 commit comments

Comments
 (0)