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

Improve Pulumi Logger behaviour #1526

Conversation

jemrobinson
Copy link
Member

✅ Checklist

  • You have given your pull request a meaningful title (e.g. Enable foobar integration rather than 515 foobar).
  • You are targeting the appropriate branch. If you're not certain which one this is, it should be develop.
  • Your branch is up-to-date with the target branch (it probably was when you started, but it may have changed since then).
  • You have marked this pull request as a draft and added '[WIP]' to the title if needed (if you're not yet ready to merge).
  • You have formatted your code using appropriate automated tools (for example ./tests/AutoFormat_Powershell.ps1 -TargetPath <path to file or directory> for Powershell).

⤴️ Summary

  • Make LoggingSingleton inherit from Singleton metaclass
  • Make LoggingSingleton a logging.logger (so line-by-line tracebacks will work correctly)

🌂 Related issues

🔬 Tests

Tested on running deployment

@jemrobinson jemrobinson merged commit 3aacc39 into alan-turing-institute:python-migration Jul 27, 2023
6 checks passed
@JimMadge
Copy link
Member

I like this, the singleton metaclass looks really clean and simple 👍.

I don't think I've used a metaclass before 👀.

@jemrobinson
Copy link
Member Author

Still has a problem that you can't use logging.getLogger("data_safe_haven") as this will return a logging.Logger not LoggingSingleton so type-hinting would break if you call logging.getLogger().custom_function().

Hopefully using logger = LoggingSingleton() or simply LoggingSingleton().info("my message") is sufficiently easy syntax to understand.

@jemrobinson jemrobinson deleted the pulumi-better-logger branch April 19, 2024 11:00
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.

2 participants