Skip to content

Add --log-level CLI flag for runtime debugging #702

@corylanou

Description

@corylanou

Currently, the log level in Litestream can only be configured through the configuration file. While this aligns with the project's philosophy of keeping database and replica configuration in the config file, there are scenarios where adjusting the log level at runtime without modifying the configuration would be beneficial.

Problem

When debugging issues or monitoring Litestream behavior, users need to:

  1. Edit the configuration file to change the log level
  2. Restart Litestream
  3. Remember to revert the configuration change afterward

This workflow is cumbersome, especially in production environments where configuration files may be managed by automation tools or where quick debugging is needed.

Proposed Solution

Add a --log-level CLI flag that overrides the configuration file setting when provided:

litestream replicate -config /etc/litestream.yml --log-level debug

This would:

  • Keep the existing configuration file logging.level setting as the default
  • Allow temporary override via CLI flag for debugging sessions
  • Follow the pattern used by many other tools where operational parameters (like verbosity) can be adjusted at runtime

Implementation Notes

  • The flag would accept values: debug, info, warn, error
  • CLI flag takes precedence over config file setting when specified
  • This aligns with keeping database/replica configuration in the config file while allowing operational adjustments via CLI

Benefits

  1. Easier debugging: Quick log level changes without config file modifications
  2. Better ops experience: Temporary verbose logging without permanent config changes
  3. Cleaner separation: Keeps operational controls (log level) separate from data configuration (databases/replicas)
  4. Familiar pattern: Many CLI tools support -v or --log-level flags for runtime verbosity control

This proposal maintains the project's philosophy of not putting database/replica configuration in CLI arguments while providing a quality-of-life improvement for operational tasks.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions