Skip to content

Conversation

@david-garcia-garcia
Copy link
Contributor

Fixes #275

_, err := fmt.Fprint(rw, bouncer.banTemplateString)
if err != nil {
bouncer.log.Error("handleBanServeHTTP could not write template to ResponseWriter")
bouncer.log.Warn("handleBanServeHTTP could not write template to ResponseWriter: " + err.Error())
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here you are using the loglevel with "bouncer.log.LOGLEVEL",

Above for Trace, you are using bouncer.log.Log(context, logger.LEVEL)
Is it possible to have it written the same way ?

What's the difference except adding the "context"

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes... I did not like that either. The thing is that slog only has convenience methods for the out of the box log levels. I solved that by adding a wrapper so log calls are now consistent.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice, with the wrapper, code looks more readable

@mathieuHa
Copy link
Collaborator

Hi @david-garcia-garcia,

First thank you for the contribution, I think adding JSON and common log format option is a great addition to the plugin.
I have some remarks, and I will need to do a bit of testing to see it in action.

You have added log level=Trace, but every log level DEBUG has been replaced by TRACE.
This would require to change the issue template to ask for Debug logs and TRACE.

I think adding TRACE could be interesting for some really verbose actions, but not all.
Currently the debug mode is unused, from what i've seen.

@david-garcia-garcia
Copy link
Contributor Author

@mathieuHa

You have added log level=Trace, but every log level DEBUG has been replaced by TRACE.
This would require to change the issue template to ask for Debug logs and TRACE.

IMHO trace would be anything that happens on a per request basis and is expected. It can be discussed.

Currently the debug mode is unused, from what i've seen.

It is, but mostly for background tasks (stream, ticker) and not as part of the request execution pipeline.

@mathieuHa
Copy link
Collaborator

On my side this looks good, only thing missing would be to edit issue template and ask for trace logs by default to throubleshoot

https://github.com/maxlerebourg/crowdsec-bouncer-traefik-plugin/blob/main/.github/ISSUE_TEMPLATE/bug_report.md

@maxlerebourg ?

@maxlerebourg
Copy link
Owner

I remove the trace log level and use all the other to do the same result as you want.
Tell me if it is ok for you ?

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.

[FEATURE] Improve logging

3 participants