Skip to content

Commit 01b194e

Browse files
Merge pull request #1 from akvadrako/master
enable logging and document how to set level
2 parents b665938 + 8104c74 commit 01b194e

File tree

3 files changed

+9
-1
lines changed

3 files changed

+9
-1
lines changed

README.md

+7
Original file line numberDiff line numberDiff line change
@@ -45,3 +45,10 @@ aws cloudformation deploy \
4545
--parameter-overrides LogRetentionInDays=30
4646
```
4747
This will install the log minder in your AWS account and run every hour.
48+
49+
## verbose
50+
51+
```sh
52+
export LOG_LEVEL=INFO
53+
cwlog-minder ...
54+
```

src/aws_cloudwatch_log_minder/__main__.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
@click.option('--dry-run', is_flag=True, default=False,
1010
help='do not change anything, just show what is going to happen')
1111
def main(ctx, dry_run):
12+
logging.basicConfig(level=os.getenv("LOG_LEVEL", "WARN"))
1213
ctx.obj = ctx.params
1314

1415
@main.command(name='set-log-retention')
@@ -25,5 +26,4 @@ def delete_empty_log_streams_command(ctx, log_group_name_prefix, purge_non_empty
2526
delete_empty_log_streams(log_group_name_prefix, purge_non_empty, ctx.obj['dry_run'])
2627

2728
if __name__ == '__main__':
28-
logging.basicConfig(level=os.getenv("LOG_LEVEL", "INFO"))
2929
main()

src/aws_cloudwatch_log_minder/delete_empty_log_streams.py

+1
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,7 @@ def delete_empty_log_streams(log_group_name_prefix: str = None, purge_non_empty:
9999
if log_group_name_prefix:
100100
kwargs["logGroupNamePrefix"] = log_group_name_prefix
101101

102+
log.info("finding log groups with prefix %r", log_group_name_prefix)
102103
for response in cw_logs.get_paginator("describe_log_groups").paginate(**kwargs):
103104
for group in response["logGroups"]:
104105
_delete_empty_log_streams(group, purge_non_empty, dry_run)

0 commit comments

Comments
 (0)