Skip to content
This repository was archived by the owner on Jun 20, 2023. It is now read-only.

logging module instead of prints #178

@dirkgomez

Description

@dirkgomez

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?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions