Unable to set no-color log output

Bug #2038917 reported by Yong-Hwan Baek
12
This bug affects 2 people
Affects Status Importance Assigned to Milestone
oslo.log
Fix Released
Wishlist
Takashi Kajinami

Bug Description

Hello

I am building a custom app using oslo.log running on apache httpd server. (We use olso to communicate with openstack services)
This app is deployed in kubernetes environment, so logs are collected through fluentd or like that.

In this situation every log prints ascii escape character(\x1b[00m) to reset terminal color.

Unfortunately, there is no way to remove or disable ascii escape character.
In configuration file setup process, every option fallbacks to ColorHandler.(https://opendev.org/openstack/oslo.log/src/commit/b5b8c30b0d925aa3d31b58932c94586631827b62/oslo_log/log.py#L365)

There are three handlers implemented (syslog, journal, color) but non of those can generate plain text without console color characters. (see. https://opendev.org/openstack/oslo.log/src/branch/master/oslo_log/handlers.py)

Could be a workaround to solve this issue?

Changed in oslo.log:
importance: Undecided → Wishlist
status: New → Confirmed
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix proposed to oslo.log (master)

Fix proposed to branch: master
Review: https://review.opendev.org/c/openstack/oslo.log/+/914791

Changed in oslo.log:
status: Confirmed → In Progress
Revision history for this message
Takashi Kajinami (kajinamit) wrote :

This is considered a new feature rather than bug fix. We can add a new option but this is not backportable.

One potential workaround is using json format logs, or somehow drop the color tags before/after the logs are processed by fluenntd.

Changed in oslo.log:
assignee: nobody → Takashi Kajinami (kajinamit)
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to oslo.log (master)

Reviewed: https://review.opendev.org/c/openstack/oslo.log/+/914791
Committed: https://opendev.org/openstack/oslo.log/commit/cdda78eab09e46f82ef6c156d645c570f408c3eb
Submitter: "Zuul (22348)"
Branch: master

commit cdda78eab09e46f82ef6c156d645c570f408c3eb
Author: Takashi Kajinami <email address hidden>
Date: Sun Mar 31 03:17:18 2024 +0900

    Add option to disable color

    Introduce an option to disable color keys which are set according to
    log levels, so that the log sent to stdout/stderr is more machine
    readable.

    Closes-Bug: #2038917
    Change-Id: I7966d4f4977b267f620946de4a5509f53b043652

Changed in oslo.log:
status: In Progress → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.