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

Make logger configurable #554

Merged
merged 1 commit into from
Jan 11, 2021
Merged

Make logger configurable #554

merged 1 commit into from
Jan 11, 2021

Conversation

ansd
Copy link
Member

@ansd ansd commented Jan 8, 2021

Before this PR, the cluster operator always used a hard-coded logger dev mode, even in production.

After this PR, the logger is prod mode by default.
This means from now on, by default, the logger will log at Info level and output JSON.

When developing locally deploying the operator using make deploy-dev and make deploy-kind, the logger will use dev mode.

Furthermore, users can now configure more zap flags (see https://github.com/kubernetes-sigs/controller-runtime/blob/66537ca5b7439b06f2f3b08901640f934834c9a1/pkg/log/zap/zap.go#L227-L233)

For example, they can set the log level as follows:

apiVersion: apps/v1
kind: Deployment
metadata:
 ...
spec:
 ...
    spec:
      containers:
      - name: operator
        command:
        - /manager
        args:
        - --zap-log-level=error

This resolves #551.

For more context, read https://sdk.operatorframework.io/docs/building-operators/golang/references/logging/.

Before this commit, the cluster operator always used a logger dev mode,
even in production.

After this commit, the logger is prod mode by default.

When developing locally deploying the operator using `make deploy-dev` and
`make deploy-kind`, the logger will use dev mode.

Futhermore, users can now configure more zap flags (see
https://github.com/kubernetes-sigs/controller-runtime/blob/66537ca5b7439b06f2f3b08901640f934834c9a1/pkg/log/zap/zap.go#L227-L233)
For example, they can set the log level.
Copy link
Contributor

@coro coro left a comment

Choose a reason for hiding this comment

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

LGTM!

Copy link
Contributor

@ChunyiLyu ChunyiLyu left a comment

Choose a reason for hiding this comment

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

We should document this improvement as well.

@ChunyiLyu ChunyiLyu merged commit bba233e into main Jan 11, 2021
@ChunyiLyu ChunyiLyu deleted the logger branch January 11, 2021 09:19
ansd added a commit to rabbitmq/messaging-topology-operator that referenced this pull request Sep 3, 2021
Before this commit, devMode was hard-coded.

Resolves #222

Same as done in rabbitmq/cluster-operator#554
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.

Set log_level through env variable or a flag
3 participants