Skip to content

Commit

Permalink
Add ability to log to CloudWatch Logs
Browse files Browse the repository at this point in the history
  • Loading branch information
prplecake committed Jan 27, 2025
1 parent c0dad15 commit a064a46
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
6 changes: 6 additions & 0 deletions find_posts.py
Original file line number Diff line number Diff line change
Expand Up @@ -1480,6 +1480,12 @@ def report_mastodon_error(error_message, error_code, access_token, required_scop
logger.critical(f"Config file {arguments.config} doesn't exist")
sys.exit(1)

if(arguments.boto3_profile_name != None):
import watchtower
watchtowerHandler = watchtower.CloudWatchLogHandler(boto3_profile_name=arguments.boto3_profile_name)
watchtowerHandler.formatter.add_log_record_attrs = ["levelname", "process", "thread"]
logger.addHandler(watchtowerHandler)

for envvar, value in os.environ.items():
envvar = envvar.lower()
if envvar.startswith("ff_") and not envvar.startswith("ff_access_token"):
Expand Down
7 changes: 6 additions & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1,15 +1,20 @@
boto3==1.36.6
botocore==1.36.6
certifi==2024.7.4
charset-normalizer==3.0.1
defusedxml==0.7.1
docutils==0.19
idna==3.7
iniconfig==2.0.0
jmespath==1.0.1
packaging==24.1
pluggy==1.5.0
pytest==8.2.2
python-dateutil==2.8.2
requests==2.32.0
s3transfer==0.11.2
six==1.16.0
smmap==5.0.0
urllib3==1.26.19
xxhash==3.4.1
watchtower==3.3.1
xxhash==3.4.1

0 comments on commit a064a46

Please sign in to comment.