Skip to content

Allow granian log level to be set#6131

Merged
adhami3310 merged 1 commit intomainfrom
masenf/granian-log-level-configure
Feb 12, 2026
Merged

Allow granian log level to be set#6131
adhami3310 merged 1 commit intomainfrom
masenf/granian-log-level-configure

Conversation

@masenf
Copy link
Collaborator

@masenf masenf commented Feb 12, 2026

User can set GRANIAN_LOG_LEVEL environment variable to override the default "critical" value.

User can set GRANIAN_LOG_LEVEL environment variable to override the default
"critical" value.
@codspeed-hq
Copy link

codspeed-hq bot commented Feb 12, 2026

Merging this PR will not alter performance

✅ 8 untouched benchmarks


Comparing masenf/granian-log-level-configure (e01a62e) with main (252223f)

Open in CodSpeed

@greptile-apps
Copy link
Contributor

greptile-apps bot commented Feb 12, 2026

Greptile Overview

Greptile Summary

Changed granian production backend to use environment variable GRANIAN_LOG_LEVEL for log level configuration instead of hardcoded --log-level critical CLI flag. This allows users to override the default "critical" log level by setting the environment variable.

Key changes:

  • Removed *("--log-level", "critical") from granian command line arguments
  • Added GRANIAN_LOG_LEVEL environment variable with default value "critical" (only set if not already present in environment)
  • Pattern follows existing GRANIAN_WORKERS environment variable handling

Minor inconsistencies noted:

  • The loglevel function parameter (line 657) remains unused, unlike the dev mode implementation which uses it
  • String literals could be extracted to constants per project style guidelines

Confidence Score: 4/5

  • This PR is safe to merge with minimal risk
  • The change is straightforward and follows existing patterns in the codebase. It moves log level configuration from a CLI flag to an environment variable, maintaining backward compatibility by defaulting to "critical". The implementation is consistent with how GRANIAN_WORKERS is handled. Minor style improvements suggested but not critical.
  • No files require special attention

Important Files Changed

Filename Overview
reflex/utils/exec.py Changed granian log level from hardcoded CLI flag to environment variable, allowing user override via GRANIAN_LOG_LEVEL, but ignores the loglevel function parameter unlike dev mode and uvicorn

Last reviewed commit: e01a62e

Copy link
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

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

1 file reviewed, 2 comments

Edit Code Review Agent Settings | Greptile

Comment on lines +685 to +686
if "GRANIAN_LOG_LEVEL" not in os.environ:
extra_env["GRANIAN_LOG_LEVEL"] = "critical"
Copy link
Contributor

Choose a reason for hiding this comment

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

The function parameter loglevel on line 657 is not being used. The dev mode run_granian_backend (line 551) uses log_level=LogLevels(loglevel.value) and the uvicorn prod backend (line 644) uses *("--log-level", loglevel.value). Consider using the function parameter as the default instead of hardcoding "critical".

Comment on lines +685 to +686
if "GRANIAN_LOG_LEVEL" not in os.environ:
extra_env["GRANIAN_LOG_LEVEL"] = "critical"
Copy link
Contributor

Choose a reason for hiding this comment

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

Consider extracting "GRANIAN_LOG_LEVEL" and "critical" as named constants (same applies to "GRANIAN_WORKERS" on line 684).

Context Used: Rule from dashboard - String literals that are used as identifiers or keys should be extracted into named constants rather... (source)

Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!

@adhami3310 adhami3310 merged commit 480d93b into main Feb 12, 2026
72 of 74 checks passed
@adhami3310 adhami3310 deleted the masenf/granian-log-level-configure branch February 12, 2026 23: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