Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Colors no longer show in middleware.Logger output #1417

Closed
3 tasks done
ccampbell opened this issue Oct 8, 2019 · 5 comments
Closed
3 tasks done

Colors no longer show in middleware.Logger output #1417

ccampbell opened this issue Oct 8, 2019 · 5 comments
Labels

Comments

@ccampbell
Copy link

ccampbell commented Oct 8, 2019

Issue Description

Starting in version 4.1.7 the colors no longer show up in the middleware.Logger output for ${status}. I suspect this is because of #1336.

(Note that the output in the command line of the echo version number in my screenshots seems to have been off by one. Probably related to 09d415c.)

Checklist

  • Dependencies installed
  • No typos
  • Searched existing issues and docs

Expected behaviour

image

Actual behaviour

image

Steps to reproduce

Start a webserver and go to pages with the middleware.Logger enabled. I am using this logging format:

e.Use(middleware.LoggerWithConfig(middleware.LoggerConfig{
	Format:  "[${time_rfc3339}] ${status} ${method} ${path} (${remote_ip}) ${latency_human}\n",
}))

You can easily reproduce by adding the following to the top of your go.mod file:

replace github.com/labstack/echo/v4 v4.1.11 => github.com/labstack/echo/v4 v4.1.6

then to see it broken

replace github.com/labstack/echo/v4 v4.1.11 => github.com/labstack/echo/v4 v4.1.7

I should add that I am using MacOS 10.12.6 incase that makes a difference.

@stale
Copy link

stale bot commented Dec 7, 2019

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the wontfix label Dec 7, 2019
@ccampbell
Copy link
Author

So because there is no activity you mark legitimate regressions as wontfix? Good to know lol

@stale stale bot removed the wontfix label Dec 7, 2019
@13k
Copy link

13k commented Dec 23, 2019

Any LoggerConfig with no explicitly set Output will cause config.colorer to always be initialized with a nil output, which it must consider "not a tty", so it will be disabled.

A workaround for the issue is using LoggerWithConfig with a LoggerConfig with explicit Output set (possibly with the default (*Echo).Logger).

@stale
Copy link

stale bot commented Feb 21, 2020

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the wontfix label Feb 21, 2020
@stale stale bot closed this as completed Feb 28, 2020
@circa10a
Copy link

If anyone comes across this issue and is just looking for some copy pasta:

e.Use(middleware.LoggerWithConfig(middleware.LoggerConfig{
	Format: "[${time_rfc3339}] ${status} ${method} ${path} (${remote_ip}) ${latency_human}\n",
	Output: e.Logger.Output(),
}))

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants