Skip to content

feat: dynamic log level via env var COCO_LOG#535

Merged
RainyNight9 merged 1 commit intomainfrom
feat/dyn_log_level
May 20, 2025
Merged

feat: dynamic log level via env var COCO_LOG#535
RainyNight9 merged 1 commit intomainfrom
feat/dyn_log_level

Conversation

@SteveLauC
Copy link
Copy Markdown
Member

@SteveLauC SteveLauC commented May 20, 2025

What does this PR do

Allow us to configure dynamic log levels via the environment variable COCO_LOG. (If it is not set, use the current default log level, INFO.)

Generally, it mirrors the behavior of env_logger. Syntax: COCO_LOG=<target>=<level>[,...], it is a log level triple sequence, separated by commas. Every log level triple consists of 3 parts:

  1. target - which is the Rust crate or module name
  2. = - an equal sign
  3. level - the log level, which is case insensitive, "TRACE" is equivalent to "tRaCe"

target and level are optional:

  • When the log level is omitted, e.g., COCO_LOG=coco_lib, the TRACE level will be used.
  • When the target is omitted, the specified log level will apply to all the targets, i.e., all the Rust crates/modules

And the log level set for a specific target has higher priority than the log level set for all the targets.

Some examples

  • I only want the logs that come from Coco-AI: COCO_LOG=coco_lib
  • I only want the Coco-AI logs with log level higher than or equal to DEBUG: COCO_LOG=coco_lib=debug
  • I want to disable Tauri's log; all the other logs should be accepted: COCO_LOG=trace,tauri=off
  • I do not want logs: COCO_LOG=off or COCO_LOG=

Rationale for this change

Standards checklist

  • The PR title is descriptive
  • The commit messages are semantic
  • Necessary tests are added
  • Updated the release notes
  • Necessary documents have been added if this is a new feature
  • Performance tests checked, no obvious performance degradation

@SteveLauC SteveLauC force-pushed the feat/dyn_log_level branch from d94d322 to 8f4e8dd Compare May 20, 2025 04:14
@RainyNight9 RainyNight9 merged commit 4372747 into main May 20, 2025
@RainyNight9 RainyNight9 deleted the feat/dyn_log_level branch May 20, 2025 04:54
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.

3 participants