-
Notifications
You must be signed in to change notification settings - Fork 1
Adding features to control if the macro uses env_logger or tracing and allow more flexibility around logging initialization/configuration
#11
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
Conversation
…nstead of log/env_logger as the log layer
…generating code with #[cfg(feature=...)] directives but that was failing because that ended-up in the user crate which did not have the features defined. Now the proc-macro crate also have the features, it inherits them from the lib crate and generates code as requested by the features.
…o make sure only one initialization code runs to avoid a panic
…abled for both env_logger and tracing feature. This feature flag controls weither or not the generated code uses log::info!(...) and log::debug!(...) statements in the 'function_handler' and the 'appsync_handler'.
…he macro to control weither or not the Lambda event is dumped in the log or not (default to true)
env_logger or tracing and allow more flexibility around logging initialization/configuration
|
Thanks for the PR It works nicely. I can provide my own tracing init with no problem. I'm a bit concerned about the default logging of the full LambdaEvent... I think this shouldn't be your lib's responsibility, at least not by default. Lambda events can contain sensitive information (API keys, bearer tokens, personal information), and having this information in the logs by default is a red flag for many organizations. |
|
In fact, there is 3 new feature flags that comes with this pull request (as mentioned):
In addition to the
My rational here is 1/ not cause a breaking change and 2/ I believe most of the time you do want to log the entire event. I hear you when you say this should not be the responsibility of my lib, but I respectfully disagree in this particular case: as I propose a procedural macro generating the lambda main and boilerplate, I'm the only one who can log the event. That being said, if you have a Lambda function handling secrets, you can disable the event dump. So the way I see it:
NB: Currently, the |
I would say, from a security standpoint, that this should be Maybe we can rename |
|
Regarding the issue with the inline JSON string in the log. tracing's standard macros don't natively support logging serde_json::Value as structured nested JSON. The {} and {:?} formatters always produce strings. A possible solution will be to use tracing's valuable feature (if integrated). This requires the valuable feature and Valuable trait implementation. |
… that, if true, it logs at debug level instead of info.
Unfortunately that's impossible, because the log_init code must be called in the Then there is already the I could add another option, maybe named (e.g.)
Yeah you are right I can't argue against that. I suppose a mild breaking change to modify that would be acceptable. So it is done.
And do you feel it is necessary to implement that? If yes, can you point me to existing example or describe what you expect? |
|
@dfeyer At this point I believe I'm done for this particular PR and your request for tracing support. The PR is big enough for my tastes and it will be a squash&merge so I'd rather keep it as it is. Ok? About |
|
Ok for me and thanks for this PR and the discussions |
Pull Request
Description
Please include a summary of the changes and which issue is being fixed.
Type of Change
Testing
The test suite ran successfully.
Tests had been added for the new log_init feature.
Checklist
Screenshots (if applicable)
Additional Notes
Breaking change: the lambda payload and AppsyncEvent will no longer be logged by default.