Skip to content

feat: Configure log levels #248

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

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions functions/notify_slack.py
Original file line number Diff line number Diff line change
Expand Up @@ -453,6 +453,9 @@ def lambda_handler(event: Dict[str, Any], context: Dict[str, Any]) -> str:
:param context: lambda expected context object
:returns: none
"""
log_level = os.environ.get("LOG_LEVEL", "WARN").upper()
logging.basicConfig(level=getattr(logging, log_level, logging.WARN))

if os.environ.get("LOG_EVENTS", "False") == "True":
logging.info(f"Event logging enabled: `{json.dumps(event)}`")

Expand Down
6 changes: 6 additions & 0 deletions variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,12 @@ variable "log_events" {
default = false
}

variable "log_level" {
Copy link
Member

Choose a reason for hiding this comment

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

this variable doesn't appear to be connected to the function as described - if a user changes this to INFO, how does that get propagated?

description = "The log level for the Lambda function"
type = string
default = "WARN"
}

variable "reserved_concurrent_executions" {
description = "The amount of reserved concurrent executions for this lambda function. A value of 0 disables lambda from being triggered and -1 removes any concurrency limitations"
type = number
Expand Down