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

Homogenize logs #305

Closed
sebgl opened this issue Jan 28, 2019 · 5 comments
Closed

Homogenize logs #305

sebgl opened this issue Jan 28, 2019 · 5 comments
Assignees
Labels
justdoit Continuous improvement not related to a specific feature

Comments

@sebgl
Copy link
Contributor

sebgl commented Jan 28, 2019

Things are in a rather strange state currently:

  • we use log.Info() most of the times (log level: 0)
  • sometimes, we use log.V(3) or log.V(4)
  • we don't have any flag parsing on -vvvv to adapt the level of log getting printed out
  • the controller-runtime log package pre-configures a zap logger compatible with the loggr interface, which only accepts 2 options: development or not
  • if development mode is true, we use the debug level (V(1)) and logs encoded for a better output on the terminal
  • if development is false, we use the info level (V(0)) and logs encoded as JSON
  • using V(3) or V(4) has no effect.

Recommendations from the controller-runtime team seems to be: stick to INFO for production and V(1).Info (debug) for development. See this doc and this issue.

I think we should either:

  1. comply with what controller-runtime is doing: keep current settings and use only info and debug levels
  2. configure our own logger (zap or something else), with log levels parsed from flags (-vvv)

I would personally vote for option 1 (simpler).

@barkbay
Copy link
Contributor

barkbay commented Jan 28, 2019

To be honest I was not familiar with "structured logging" as it is done in the controller-runtime 😳 Much more simpler that what I have seen before.
I like the idea to have a simple rule and stick with V(0) and V(1)

My only concern would be to be able the turn on the debug level easily on a specific environment (c.f. --v Level with K8S components) without having to enable some "development" features that could compromise the security of a production environment.

FWIW it's a +1 for option 1, may be we can "extract" some ideas from https://github.com/kubernetes-sigs/controller-runtime/blob/master/TMP-LOGGING.md in a contributing guide ?

@pebrc
Copy link
Collaborator

pebrc commented Feb 8, 2019

I think I am also for option 1 (just use 2 levels)

The only other thing to consider maybe is that currently iirc debug level is tied to our --development mode flag.

Is it worth having the option to turn on the verbose mode in production as well when things don't go according to plan?

@pebrc pebrc added this to the Alpha milestone Feb 8, 2019
@pebrc pebrc added justdoit Continuous improvement not related to a specific feature loe:medium labels Feb 8, 2019
@pebrc
Copy link
Collaborator

pebrc commented Apr 2, 2019

We discussed this issue today during the status meeting. Some notes:

  • We still think that the two level debug/info are enough
  • We want to be able to switch the log level independently from dev mode (we are currently conflating log level and other dev specific things here e.g. port forwarding)
  • We want the ability to switch format between JSON and non-structured independently from DEBUG level (V(1))

@pebrc pebrc removed this from the Alpha milestone May 10, 2019
@anyasabo anyasabo self-assigned this Jun 21, 2019
This was referenced Jun 28, 2019
@anyasabo
Copy link
Contributor

anyasabo commented Jul 8, 2019

We want the ability to switch format between JSON and non-structured independently from DEBUG level (V(1))

Do we still think this is necessary? It looks like doing this through kubebuilder is a little bit more involved and I'm not sure what the use case is. I think we would end up mostly re-implementing this function but exposing the knobs we want:
https://github.com/kubernetes-sigs/controller-runtime/blob/v0.1.12/pkg/runtime/log/log.go#L43

If not I think we can close this issue as the other bullets are checked off now

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
justdoit Continuous improvement not related to a specific feature
Projects
None yet
Development

No branches or pull requests

5 participants