Project

General

Profile

Actions

Bug #6249

open

logging: ANSI color sequences should be reset after log message

Added by manawyrm 4 months ago. Updated 3 months ago.

Status:
In Progress
Priority:
Low
Assignee:
Category:
libosmocore
Target version:
-
Start date:
11/07/2023
Due date:
% Done:

100%

Spec Reference:

Description

Currently, libosmocore will output color control escape sequences to print logs in a specific color.
When logging these messages to something mixed with other messages (like systemd-journald), the missing reset at the end of the message causes output like this:

Proposed fix: Output a color reset at the end of each log message. This adds 4 bytes (escape, [0m) at the end of each message, which IMHO is reasonable.


Files


Related issues

Related to libosmocore - Bug #6284: '\0' in log outputResolvedneels12/04/2023

Actions
Actions #1

Updated by laforge 4 months ago

I was actually under the assumption that this is what we did. Seems like it isn't?

Actions #2

Updated by manawyrm 4 months ago

Yes, I had a brief look at the code and there is indeed code to reset the colors after each block/message.
Not quite sure why/where the last reset is getting lost.

Could you maybe tell me about the expected behaviour? I'm guessing the text itself shouldn't be coloured at all?

Actions #4

Updated by laforge 4 months ago

On Tue, Nov 07, 2023 at 10:37:56AM +0000, manawyrm wrote:

Could you maybe tell me about the expected behaviour? I'm guessing the text itself shouldn't be coloured at all?

that all depends on your log configuration. It supports a large variety of modes. In the
default mode, indeed the whole line would be colored according to the sub-system log color. Each subsystem
uses a different color.

Actions #5

Updated by manawyrm 4 months ago

  • Status changed from New to Resolved
  • % Done changed from 0 to 100
Actions #6

Updated by neels 3 months ago

The patch
https://osmocom.org/projects/libosmocore/repository/libosmocore/revisions/11a416827dd9f2da6b7c1db0e1e83adb1e6e5cc8/diff
causes a bug:
https://osmocom.org/issues/6284 "'\0' in log output" (almost all osmo cni programs)

I don't understand why yet, but reverting the patch fixes the issue.

Actions #7

Updated by neels 3 months ago

  • Related to Bug #6284: '\0' in log output added
Actions #8

Updated by neels 3 months ago

  • Status changed from Resolved to In Progress
Actions

Also available in: Atom PDF

Add picture from clipboard (Maximum size: 48.8 MB)