@@ -284,14 +284,28 @@ def __init__(self, filename, when='h', interval=1, backupCount=0,
284284 if os .path .exists (filename ):
285285 # Use the minimum of file creation and modification time as
286286 # the base of the rollover calculation
287- stat_result = os .stat (filename )
288- # Use st_birthtime whenever it is available or use st_ctime
289- # instead otherwise
290- try :
291- creation_time = stat_result .st_birthtime
292- except AttributeError :
293- creation_time = stat_result .st_ctime
294- t = int (min (creation_time , stat_result .st_mtime ))
287+ creation_time = modification_time = None
288+ if hasattr (os , 'statx' ):
289+ statx_result = os .statx (filename ,
290+ os .STATX_BTIME | os .STATX_CTIME | os .STATX_MTIME )
291+ # Use stx_btime whenever it is available or use stx_ctime
292+ # instead otherwise
293+ creation_time = statx_result .stx_btime
294+ if creation_time is None :
295+ creation_time = statx_result .stx_ctime
296+ modification_time = statx_result .stx_mtime
297+ if creation_time is None or modification_time is None :
298+ stat_result = os .stat (filename )
299+ # Use st_birthtime whenever it is available or use st_ctime
300+ # instead otherwise
301+ if creation_time is None :
302+ try :
303+ creation_time = stat_result .st_birthtime
304+ except AttributeError :
305+ creation_time = stat_result .st_ctime
306+ if modification_time is None :
307+ modification_time = stat_result .st_mtime
308+ t = int (min (creation_time , modification_time ))
295309 else :
296310 t = int (time .time ())
297311 self .rolloverAt = self .computeRollover (t )
0 commit comments