Skip to content

Commit b8aed8d

Browse files
committed
Clean up logging: move exception tracebacks to debug level
Move exception info from warning to debug level in import error handlers. This provides cleaner user-facing output by default while still making detailed exception info available for troubleshooting via debug logging. Changes: - FileIO import failures (pyiceberg.io.__init__) - LocationProvider import failures (pyiceberg.table.locations) - Catalog import failures (pyiceberg.catalog.__init__) - File deletion failures (pyiceberg.catalog.__init__) Users now see clean one-line warnings instead of full tracebacks. Developers can enable debug logging to see detailed exception info.
1 parent b0a7878 commit b8aed8d

File tree

3 files changed

+10
-5
lines changed

3 files changed

+10
-5
lines changed

pyiceberg/catalog/__init__.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -286,7 +286,8 @@ def delete_files(io: FileIO, files_to_delete: set[str], file_type: str) -> None:
286286
try:
287287
io.delete(file)
288288
except OSError as exc:
289-
logger.warning(msg=f"Failed to delete {file_type} file {file}", exc_info=exc)
289+
logger.warning(msg=f"Failed to delete {file_type} file {file}")
290+
logger.debug(f"Error deleting {file_type} file {file}", exc_info=exc)
290291

291292

292293
def delete_data_files(io: FileIO, manifests_to_delete: list[ManifestFile]) -> None:
@@ -306,7 +307,8 @@ def delete_data_files(io: FileIO, manifests_to_delete: list[ManifestFile]) -> No
306307
try:
307308
io.delete(path)
308309
except OSError as exc:
309-
logger.warning(msg=f"Failed to delete data file {path}", exc_info=exc)
310+
logger.warning(msg=f"Failed to delete data file {path}")
311+
logger.debug(f"Error deleting data file {path}", exc_info=exc)
310312
deleted_files[path] = True
311313

312314

@@ -320,7 +322,8 @@ def _import_catalog(name: str, catalog_impl: str, properties: Properties) -> Cat
320322
class_ = getattr(module, class_name)
321323
return class_(name, **properties)
322324
except ModuleNotFoundError as exc:
323-
logger.warning(f"Could not initialize Catalog: {catalog_impl}", exc_info=exc)
325+
logger.warning(f"Could not initialize Catalog: {catalog_impl}")
326+
logger.debug(f"Failed to load {catalog_impl}", exc_info=exc)
324327
return None
325328

326329

pyiceberg/io/__init__.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -322,7 +322,8 @@ def _import_file_io(io_impl: str, properties: Properties) -> FileIO | None:
322322
class_ = getattr(module, class_name)
323323
return class_(properties)
324324
except ModuleNotFoundError as exc:
325-
logger.warning(f"Could not initialize FileIO: {io_impl}", exc_info=exc)
325+
logger.warning(f"Could not initialize FileIO: {io_impl}")
326+
logger.debug(f"Failed to load {io_impl}", exc_info=exc)
326327
return None
327328

328329

pyiceberg/table/locations.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,8 @@ def _import_location_provider(
179179
class_ = getattr(module, class_name)
180180
return class_(table_location, table_properties)
181181
except ModuleNotFoundError as exc:
182-
logger.warning(f"Could not initialize LocationProvider: {location_provider_impl}", exc_info=exc)
182+
logger.warning(f"Could not initialize LocationProvider: {location_provider_impl}")
183+
logger.debug(f"Failed to load {location_provider_impl}", exc_info=exc)
183184
return None
184185

185186

0 commit comments

Comments
 (0)