bluesentry / bucket-antivirus-function

Serverless antivirus for cloud storage.
Apache License 2.0
536 stars 389 forks source link

logging module instead of prints #178

Open dirkgomez opened 3 years ago

dirkgomez commented 3 years ago

I've replaced straight prints with the Python logging module in my repository: https://github.com/dirkgomez/bucket-antivirus-function/blob/master/, e. g. like this:

+logging.getLogger().setLevel(level=os.getenv("LOG_LEVEL", logging.INFO))

 def update_defs_from_s3(s3_client, bucket, prefix):
     create_dir(AV_DEFINITION_PATH)
@@ -60,13 +52,13 @@ def update_defs_from_s3(s3_client, bucket, prefix):
             s3_time = time_from_s3(s3_client, bucket, s3_path)

             if s3_best_time is not None and s3_time < s3_best_time:
-                print("Not downloading older file in series: %s" % filename)
+                logging.info("Not downloading older file in series: %s" % filename)
                 continue
             else:
                 s3_best_time = s3_time

Advantages: it's configurable from within the source code what is getting logging and also from an environment variable passed into the lambda.

Would you accept a PR?

YesemKebede commented 3 years ago

@dirkgomez could you submit a PR for this?