55from datetime import datetime , timedelta
66
77import jmespath
8+ from loguru import logger
89
910
1011def extract_region_from_zone (zone : str ):
@@ -111,7 +112,7 @@ def filter_backups_into_recent_and_old(
111112 if datetime .now () - backup ["createTime" ] > timedelta (days = retention_days )
112113 ]
113114 if len (old_backups ) > 0 :
114- print (
115+ logger . info (
115116 f"Filestore backups older than { retention_days } days have been found. They will be deleted." # noqa: E501
116117 )
117118
@@ -140,7 +141,7 @@ def create_backup_if_necessary(
140141 zone (str): The GCP zone to create the backup in, e.g. us-central1-b
141142 """
142143 if len (backups ) == 0 :
143- print (
144+ logger . info (
144145 f"There have been no recent backups of the filestore for project { project } . Creating a backup now..." # noqa: E501
145146 )
146147
@@ -168,7 +169,7 @@ def create_backup_if_necessary(
168169 ]
169170 )
170171 else :
171- print ("Recent backup found." )
172+ logger . info ("Recent backup found." )
172173
173174
174175def delete_old_backups (backups : list , region : str ):
@@ -192,7 +193,7 @@ def delete_old_backups(backups: list, region: str):
192193 ]
193194 )
194195 else :
195- print ("No outdated backups found." )
196+ logger . info ("No outdated backups found." )
196197
197198
198199def main (args ):
@@ -264,6 +265,7 @@ def main(args):
264265 )
265266
266267 args = parser .parse_args ()
268+ logger .info (f"Parsed arguments: { vars (args )} " )
267269
268270 while True :
269271 main (args )
0 commit comments