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

Set the log level to LOG_LEVEL env variable #417

Merged
merged 4 commits into from
Nov 7, 2024

Conversation

sebsto
Copy link
Contributor

@sebsto sebsto commented Oct 26, 2024

Set the log level to LOG_LEVEL env variable

Motivation:

LOG_LEVEL environment variable was not used

Modifications:

I made the following changes to LambdaRuntime

  • transform log from let to var (I hope it does not impact Swift 6 language mode)
  • Set the logger logLevel to the value of the ENV varaibale, defaulting to .info when the value is incorrect or not set

By setting the log level at the creation of the runtime, before entering in the loop, I know that a change of the value in the Lambda console will not affect running microVM. Only microVM launched after the change will pick up the new value, which will eventually affect all containers as the Lambda service replaces microVM on a regular basis.

The alternative is to set the log level before each invocation of the user-provided handler. This approach would be less performant as it would require to read the environment variable at each invocation of the runtime, not only at the start.

This is a tradeoff for performance instead of flexibility.

Result:

It is now possible to write context.logger.debug("..") and read the line in CloudWatch logs

@sebsto sebsto merged commit 7016dfc into swift-server:main Nov 7, 2024
23 of 24 checks passed
@sebsto sebsto deleted the sebsto/log_level branch November 7, 2024 08:49
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