File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -299,7 +299,9 @@ def _add_file_sink(
299299 ) -> int :
300300 os .makedirs (os .path .dirname (file_path ) or "." , exist_ok = True )
301301 rotation = f"{ max_mb } MB" if max_mb and max_mb > 0 else None
302- retention = f"{ backup_count } files" if rotation else None
302+ retention = (
303+ backup_count if rotation and backup_count and backup_count > 0 else None
304+ )
303305 if trace :
304306 return _loguru .add (
305307 file_path ,
@@ -363,13 +365,16 @@ def configure_logger(
363365 if not enable_file :
364366 return
365367
366- cls ._file_sink_id = cls ._add_file_sink (
367- file_path = cls ._resolve_log_path (file_path ),
368- level = logger .level ,
369- max_mb = max_mb ,
370- backup_count = 3 ,
371- trace = False ,
372- )
368+ try :
369+ cls ._file_sink_id = cls ._add_file_sink (
370+ file_path = cls ._resolve_log_path (file_path ),
371+ level = logger .level ,
372+ max_mb = max_mb ,
373+ backup_count = 3 ,
374+ trace = False ,
375+ )
376+ except Exception as e :
377+ logger .error (f"Failed to add file sink: { e } " )
373378
374379 @classmethod
375380 def configure_trace_logger (cls , config : dict | None ) -> None :
You can’t perform that action at this time.
0 commit comments