Skip to content

Conversation

@HugoW5
Copy link

@HugoW5 HugoW5 commented Oct 21, 2025

Description:

  • Updated the debug log format to a simpler, color-free string suitable for JSON output.
  • Removed the colorForResponseCode function as it is no longer required.
  • This resolves improper ANSI escape sequences and non-ASCII characters (e.g., µs) appearing in remote logger JSON logs.

When using the remote logger, debug logs contained ANSI color codes and the µs symbol, which caused JSON parsing issues in downstream log processors.
This update ensures the debug logs remain clean and machine-readable.

Related Issue

Fixes #2281

Additional Information:

Before

{"level":"DEBUG","message":"\u001b[38;5;8m5460fd91... µs GET ..."}

After

{"level":"DEBUG","message":"5460fd91... 5855us GET ..."}

Checklist:

  • I have formatted my code using goimport and golangci-lint.
  • All new code is covered by unit tests.
  • This PR does not decrease the overall code coverage.
  • I have reviewed the code comments and documentation for clarity.

Thank you for your contribution!

HugoW5 and others added 4 commits October 21, 2025 18:41
@HugoW5
Copy link
Author

HugoW5 commented Oct 23, 2025

@Umang01-hash 👋

The CI is currently failing on PKG Unit Testing (v1.25), but it looks like the issue isn’t with the tests themselves — they’re passing locally and on the other Go versions.

The logs show:

Failed to load config from file: /.env, Err: open /.env: no such file or directory

@Umang01-hash
Copy link
Member

@HugoW5 Can you please help me how did we reproduced the issue as for me the logs were appearing fine.
Screenshot 2025-10-23 at 2 13 34 PM

Also we need to maintain a consistency in logs, removing the color from logs is not the best approach as it will lead to inconsitent logs for different log levels which should not be the case.

And the changes in go.sum is also not needed.

@Umang01-hash
Copy link
Member

@HugoW5 Thanks i got the issue. But again we can't skip the color formatting part as it will lead to inconsistent logs (refer to the attached image, the response status code and time to execute shows green in INFO but white in DEBUG)

Screenshot 2025-10-23 at 2 31 04 PM

@HugoW5
Copy link
Author

HugoW5 commented Oct 23, 2025

@Umang01-hash
Yes, I dont know the exact way of how the author of the issue got the bug. I only get it when writing stdout to a file.
I will look in to this issue again and try to propose a better solution.

Closing this pr and making a new one for the correct solution.

@HugoW5 HugoW5 closed this Oct 23, 2025
@HugoW5
Copy link
Author

HugoW5 commented Oct 23, 2025

Resolved the issue with debug log formatting for terminal and non-terminal outputs, ensuring colored logs in terminals and clean JSON logs for file output.
In this PR
#2464

@HugoW5 HugoW5 deleted the fix-formatting-remote-debug-log branch October 23, 2025 17:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Improper formatting in gofr debug log for remote logger

2 participants