Skip to content

OBPIH-6858 enable color logs for dev and testing only#4959

Merged
awalkowiak merged 2 commits intodevelopfrom
bug/OBPIH-6858-disable-color-logs-in-prod
Nov 28, 2024
Merged

OBPIH-6858 enable color logs for dev and testing only#4959
awalkowiak merged 2 commits intodevelopfrom
bug/OBPIH-6858-disable-color-logs-in-prod

Conversation

@ewaterman
Copy link
Member

✨ Description of Change

A concise summary of what is being changed. Please provide enough context for reviewers to be able to understand the change and why it is necessary. If the issue/ticket already provides enough information, you can put "See ticket" as the description.

Link to GitHub issue or Jira ticket: https://pihemr.atlassian.net/browse/OBPIH-6858

Description: Disable ANSI Logback colors in prod so that we don't get gross log output like this when the terminal can't parse them properly:

image

@ewaterman ewaterman self-assigned this Nov 27, 2024
@github-actions github-actions bot added type: bug Addresses unintended behaviours of the app flag: config change Hilights a pull request that contains a change to the app config labels Nov 27, 2024
# we don't want to break any log processors in production. https://logback.qos.ch/manual/layouts.html
logging:
pattern:
console: "%cyan(%date{ISO8601}) %highlight(%-5level) %magenta([%thread]) %yellow(%logger{40}): %message%n%xException"
Copy link
Member Author

@ewaterman ewaterman Nov 27, 2024

Choose a reason for hiding this comment

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

I originally tried doing this via Grails' environment properties:

environments:
    development:
        logging:
            pattern:
                console: <pattern with colors>
...
logging:
    pattern:
        console: <pattern without colors>

but unfortunately the environment specific property didn't get picked up by Logback. I assume it's because the environments is a Grails thing that doesn't get properly passed down to Logback.

@codecov
Copy link

codecov bot commented Nov 27, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 7.62%. Comparing base (7c08257) to head (8b8c3ea).
Report is 91 commits behind head on develop.

Additional details and impacted files
@@             Coverage Diff              @@
##             develop   #4959      +/-   ##
============================================
- Coverage       7.62%   7.62%   -0.01%     
+ Complexity       818     816       -2     
============================================
  Files            600     600              
  Lines          42275   42275              
  Branches       10276   10276              
============================================
- Hits            3224    3222       -2     
  Misses         38586   38586              
- Partials         465     467       +2     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

<configuration>

<include resource="org/springframework/boot/logging/logback/defaults.xml"/>
<include resource="org/springframework/boot/logging/logback/console-appender.xml"/>
Copy link
Member Author

Choose a reason for hiding this comment

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

Copy link
Member Author

@ewaterman ewaterman Nov 28, 2024

Choose a reason for hiding this comment

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

Moved this file to test/resources so that it applies to unit tests as well (and added a comment clarifying its purpose)

@awalkowiak awalkowiak merged commit e79529a into develop Nov 28, 2024
@awalkowiak awalkowiak deleted the bug/OBPIH-6858-disable-color-logs-in-prod branch November 28, 2024 16:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

flag: config change Hilights a pull request that contains a change to the app config type: bug Addresses unintended behaviours of the app

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants