Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Logger format update #82

Merged
merged 3 commits into from
Mar 18, 2023
Merged

feat: Logger format update #82

merged 3 commits into from
Mar 18, 2023

Conversation

quixoticmonk
Copy link
Contributor

Summary

Changed the logging format to use timestamp and method line numbers to help with future debugging. Sample log lines below.

[INFO] : 2023-03-17 22:00:29 : botocore.credentials : Found credentials in environment variables.
[INFO] : 2023-03-17 22:00:30 : eksupgrade.src.preflight_module.91 : Cluster already upgraded to version 1.22

Resolves: #81

Changes

  • Added get_logger method to utils
  • Updated logger object to use the common get_logger utility
  • Formatted the logs to use log level, date/time and module line numbers.

User experience

Before:

INFO:botocore.credentials:Found credentials in environment variables.
INFO:botocore.credentials:Found credentials in environment variables.
INFO:eksupgrade.src.preflight_module:Verifying User IAM Role....
INFO:eksupgrade.src.preflight_module:IAM role for user verified
INFO:botocore.credentials:Found credentials in environment variables.
INFO:eksupgrade.src.preflight_module:Fetching cluster details .....
INFO:eksupgrade.src.preflight_module:Cluster control plane version 1.22
INFO:eksupgrade.src.preflight_module:Cluster already upgraded to version 1.22

After:

[INFO] : 2023-03-17 22:00:29 : botocore.credentials : Found credentials in environment variables.
[INFO] : 2023-03-17 22:00:29 : botocore.credentials : Found credentials in environment variables.
[INFO] : 2023-03-17 22:00:29 : eksupgrade.src.preflight_module.40 : Verifying User IAM Role....
[INFO] : 2023-03-17 22:00:30 : eksupgrade.src.preflight_module.42 : IAM role for user verified
[INFO] : 2023-03-17 22:00:30 : botocore.credentials : Found credentials in environment variables.
[INFO] : 2023-03-17 22:00:30 : eksupgrade.src.preflight_module.79 : Fetching cluster details .....
[INFO] : 2023-03-17 22:00:30 : eksupgrade.src.preflight_module.87 : Cluster control plane version 1.22
[INFO] : 2023-03-17 22:00:30 : eksupgrade.src.preflight_module.91 : Cluster already upgraded to version 1.22

Checklist

If your change doesn't seem to apply, please leave them unchecked.

  • I have performed a self-review of this change
  • Changes have been tested
  • Changes are documented

Acknowledgment

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

Disclaimer: We value your time and bandwidth. As such, any pull requests created on non-triaged issues might not be successful.

@codecov-commenter
Copy link

codecov-commenter commented Mar 18, 2023

Codecov Report

Patch coverage: 96.77% and project coverage change: +0.37 🎉

Comparison is base (a88f478) 27.51% compared to head (a69bc4c) 27.88%.

📣 This organization is not using Codecov’s GitHub App Integration. We recommend you install it so Codecov can continue to function properly for your repositories. Learn more

Additional details and impacted files
@@            Coverage Diff             @@
##             main      #82      +/-   ##
==========================================
+ Coverage   27.51%   27.88%   +0.37%     
==========================================
  Files          13       13              
  Lines        1912     1922      +10     
==========================================
+ Hits          526      536      +10     
  Misses       1386     1386              
Impacted Files Coverage Δ
eksupgrade/cli.py 93.10% <66.66%> (+0.24%) ⬆️
eksupgrade/models/base.py 82.22% <100.00%> (ø)
eksupgrade/models/eks.py 60.29% <100.00%> (ø)
eksupgrade/src/boto_aws.py 10.84% <100.00%> (ø)
eksupgrade/src/eks_get_image_type.py 14.54% <100.00%> (ø)
eksupgrade/src/k8s_client.py 28.18% <100.00%> (-0.33%) ⬇️
eksupgrade/src/latest_ami.py 19.23% <100.00%> (ø)
eksupgrade/src/preflight_module.py 4.40% <100.00%> (ø)
eksupgrade/src/self_managed.py 16.00% <100.00%> (ø)
eksupgrade/starter.py 13.33% <100.00%> (ø)
... and 1 more

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

☔ View full report in Codecov by Sentry.
📢 Do you have feedback about the report comment? Let us know in this issue.

@quixoticmonk quixoticmonk requested a review from a team March 18, 2023 02:35
@@ -13,3 +14,16 @@ def get_package_dict(filename: str, base_path: str = "src/S3Files/"):
"""Get the specified package asset data dictionary."""
_data = get_package_asset(filename, base_path)
return json.loads(_data)


def get_logger(logger_name):
Copy link
Contributor

@mbeacom mbeacom Mar 18, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit - return type and argument type here

@mbeacom mbeacom merged commit 088bca6 into aws-samples:main Mar 18, 2023
@quixoticmonk quixoticmonk deleted the feat/logger-format branch March 22, 2023 02:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Maintenance: Update logger to use timestamps
4 participants