77from pathlib import Path
88from typing import Optional , Union , Callable , Any , overload
99import io
10- from .lib import dynamically_load_library
10+ from .lib import dynamically_load_library , logger
1111import mimetypes
1212
1313# Define required function names
@@ -1147,9 +1147,9 @@ def close(self):
11471147 try :
11481148 _lib .c2pa_release_stream (self ._stream )
11491149 except Exception as e :
1150- print (
1150+ logger . error (
11511151 Stream ._ERROR_MESSAGES ['stream_error' ].format (
1152- str (e )), file = sys . stderr )
1152+ str (e )))
11531153 finally :
11541154 self ._stream = None
11551155
@@ -1159,14 +1159,14 @@ def close(self):
11591159 try :
11601160 setattr (self , attr , None )
11611161 except Exception as e :
1162- print (
1162+ logger . error (
11631163 Stream ._ERROR_MESSAGES ['callback_error' ].format (
1164- attr , str (e )), file = sys . stderr )
1164+ attr , str (e )))
11651165
11661166 except Exception as e :
1167- print (
1167+ logger . error (
11681168 Stream ._ERROR_MESSAGES ['cleanup_error' ].format (
1169- str (e )), file = sys . stderr )
1169+ str (e )))
11701170 finally :
11711171 self ._closed = True
11721172 self ._initialized = False
@@ -1544,9 +1544,9 @@ def close(self):
15441544 self ._cleanup_resources ()
15451545 except Exception as e :
15461546 # Log any unexpected errors during close
1547- print (
1547+ logger . error (
15481548 Reader ._ERROR_MESSAGES ['cleanup_error' ].format (
1549- str (e )), file = sys . stderr )
1549+ str (e )))
15501550 finally :
15511551 self ._closed = True
15521552
@@ -1748,9 +1748,9 @@ def wrapped_callback(
17481748 # Native code expects the signed len to be returned, we oblige
17491749 return actual_len
17501750 except Exception as e :
1751- print (
1751+ logger . error (
17521752 cls ._ERROR_MESSAGES ['callback_error' ].format (
1753- str (e )), file = sys . stderr )
1753+ str (e )))
17541754 # Error: exception raised, invalid so return -1,
17551755 # native code will handle the error when seeing -1
17561756 return - 1
@@ -1856,9 +1856,9 @@ def close(self):
18561856 self ._cleanup_resources ()
18571857 except Exception as e :
18581858 # Log any unexpected errors during close
1859- print (
1859+ logger . error (
18601860 Signer ._ERROR_MESSAGES ['cleanup_error' ].format (
1861- str (e )), file = sys . stderr )
1861+ str (e )))
18621862 finally :
18631863 self ._closed = True
18641864
@@ -2088,9 +2088,9 @@ def close(self):
20882088 self ._cleanup_resources ()
20892089 except Exception as e :
20902090 # Log any unexpected errors during close
2091- print (
2091+ logger . error (
20922092 Builder ._ERROR_MESSAGES ['cleanup_error' ].format (
2093- str (e )), file = sys . stderr )
2093+ str (e )))
20942094 finally :
20952095 self ._closed = True
20962096
0 commit comments