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

Echo uses lecho and log level is missing, can we check and override ? #33

Open
iangregsondev opened this issue Nov 24, 2024 · 3 comments
Labels
enhancement New feature or request good first issue Good for newcomers

Comments

@iangregsondev
Copy link

Hi,

I have the following output, there is message that comes from ECHO but using lecho logger, it is missing the LEVEL and displays ??? instead of log level.

Is there anyway to intercept it and check if the level is actually empty? If it is, then change to INFO

2024-11-24T18:36:10Z INF cmd/node/main.go:55 > Starting application hello="This si san  error!!"
2024-11-24T18:36:10Z INF Server built
2024-11-24T18:36:10Z INF internal/node/app/app.go:25 > Starting the application...
2024-11-24T18:36:10Z ??? ⇨ http server started on [::]:9151

If I could intercept it, then this line

2024-11-24T18:36:10Z ??? ⇨ http server started on [::]:9151

Could become

2024-11-24T18:36:10Z INF ⇨ http server started on [::]:9151

I know this is not a problem of lecho, Echo is probably not including the level, but I was hoping to intercept it and replace it

Or is there a better way to do this ?

THanks in advance

Ian

@iangregsondev
Copy link
Author

iangregsondev commented Nov 24, 2024

Also, with the same subject, I added CallerWithSkipFrameCount

And it works great, but I was wondering if its possible to override (delete actually) anything that doesn't not come from my own repository

It is outputting color.go

2024-11-24T18:58:51Z INF cmd/node/main.go:55 > Starting application hello="This si san  error!!"
2024-11-24T18:58:51Z INF internal/node/di/builders/infrastructure/server/build.go:52 > Server built
2024-11-24T18:58:51Z INF internal/node/app/app.go:25 > Starting the application...
2024-11-24T18:58:51Z ??? ../../../../../.gobrew/current/go/pkg/mod/github.com/labstack/[email protected]/color/color.go:173 > ⇨ http server started on [::]:9151

@ziflex
Copy link
Owner

ziflex commented Dec 11, 2024

Hi,

I have the following output, there is message that comes from ECHO but using lecho logger, it is missing the LEVEL and displays ??? instead of log level.

Is there anyway to intercept it and check if the level is actually empty? If it is, then change to INFO

2024-11-24T18:36:10Z INF cmd/node/main.go:55 > Starting application hello="This si san  error!!"
2024-11-24T18:36:10Z INF Server built
2024-11-24T18:36:10Z INF internal/node/app/app.go:25 > Starting the application...
2024-11-24T18:36:10Z ??? ⇨ http server started on [::]:9151

If I could intercept it, then this line

2024-11-24T18:36:10Z ??? ⇨ http server started on [::]:9151

Could become

2024-11-24T18:36:10Z INF ⇨ http server started on [::]:9151

I know this is not a problem of lecho, Echo is probably not including the level, but I was hoping to intercept it and replace it

Or is there a better way to do this ?

THanks in advance

Ian

That happens when Echo calls Print or Printf methods.
I can add an optional parameter for using a default level when one of these methods gets called.

@ziflex
Copy link
Owner

ziflex commented Dec 11, 2024

Also, with the same subject, I added CallerWithSkipFrameCount

And it works great, but I was wondering if its possible to override (delete actually) anything that doesn't not come from my own repository

It is outputting color.go

2024-11-24T18:58:51Z INF cmd/node/main.go:55 > Starting application hello="This si san  error!!"
2024-11-24T18:58:51Z INF internal/node/di/builders/infrastructure/server/build.go:52 > Server built
2024-11-24T18:58:51Z INF internal/node/app/app.go:25 > Starting the application...
2024-11-24T18:58:51Z ??? ../../../../../.gobrew/current/go/pkg/mod/github.com/labstack/[email protected]/color/color.go:173 > ⇨ http server started on [::]:9151

It really depends on Echo API. If it provides such a functionality, then you could do that.
I don't know if it does, to be honest.

@ziflex ziflex added enhancement New feature or request good first issue Good for newcomers labels Dec 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

2 participants