Skip to content

Logs are colorized regardless of colorized_logging do to load order requirements of dotenv #514

@davetron5000

Description

@davetron5000

Steps to reproduce

  1. Make as new Rails app
  2. add config.colorize_logging = false to config/environments/development.rb
  3. Set up some .env files
  4. Start Rails
  5. Look at the log

Expected behavior

Log messages issued by this gem should respect the colorize_logging value in general, or in this case, not colorize its log output.

Actual behavior

dotenv's initial log messasges are colorized because dotenv loads itself and the .env files before the Rails configuration has taken place to turn off colorized logging.

[dotenv] Set ^[[36mDATABASE_URL^[[0m
[dotenv] Loaded ^[[33m.env.development^[[0m

System configuration

dotenv version: 3.1.4

Rails version: 8.0.0

Ruby version: 3.3.6

Notes

I don't see a way to tell Rails to avoid colorized logging any earlier.

I can think of two solutions:

  • Change these log messages to debug - they don't seem necessary to be at info level
  • Change the logging calls to avoid color altogether

Maybe there is a better third option I'm not thinking of?

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