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

Adding a flag for splitting log output (--log-splitting) #775

Closed
wants to merge 3 commits into from
Closed

Adding a flag for splitting log output (--log-splitting) #775

wants to merge 3 commits into from

Conversation

freddd
Copy link

@freddd freddd commented Nov 20, 2018

Fixes #772

Basically, the issue is that logrus by default pipes all logs to stderr. This displays logs as being errors when they are actually level=info, etc in Google Stackdriver and DataDog.

Because of this, we are not able to have generic alerts on errors (as all lines are seen as errors). See screenshot in #772

The simplest way to test this PR is to run the application and redirect output:

The example below will send all logs to stderr (the default behavior).

external-dns --registry txt --txt-owner-id my-cluster-id --provider google --google-project example-project --source service --once --dry-run > 1.stdout 2> 2.stderr

This example shows the --log-splitting flag

external-dns --registry txt --txt-owner-id my-cluster-id --provider google --google-project example-project --source service --once --log-splitting --dry-run > 1.stdout 2> 2.stderr

To verify it, you can just cat 1.stdout and cat 2.stderr.

References:
sirupsen/logrus#403
Azure/open-service-broker-azure#25

@k8s-ci-robot
Copy link
Contributor

Thanks for your pull request. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

📝 Please follow instructions at https://git.k8s.io/community/CLA.md#the-contributor-license-agreement to sign the CLA.

It may take a couple minutes for the CLA signature to be fully registered; after that, please reply here with a new comment and we'll verify. Thanks.


Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. I understand the commands that are listed here.

@k8s-ci-robot k8s-ci-robot added cncf-cla: no Indicates the PR's author has not signed the CNCF CLA. size/S Denotes a PR that changes 10-29 lines, ignoring generated files. labels Nov 20, 2018
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by:
To fully approve this pull request, please assign additional approvers.
We suggest the following additional approver: hjacobs

If they are not already assigned, you can assign the PR to them by writing /assign @hjacobs in a comment when ready.

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@freddd
Copy link
Author

freddd commented Nov 20, 2018

/check-cla

@k8s-ci-robot k8s-ci-robot added cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. and removed cncf-cla: no Indicates the PR's author has not signed the CNCF CLA. labels Nov 20, 2018
@freddd
Copy link
Author

freddd commented Nov 22, 2018

/assign @hjacobs

@hjacobs hjacobs removed their assignment Nov 22, 2018

// Splits log output, error and fatal to stderr and the rest to stdout
func (splitter *logOutputSplitter) Write(p []byte) (n int, err error) {
if bytes.Contains(p, []byte("level=debug")) || bytes.Contains(p, []byte("level=info")) ||
Copy link
Contributor

Choose a reason for hiding this comment

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

this looks pretty hacky I must say

Copy link
Author

@freddd freddd Nov 23, 2018

Choose a reason for hiding this comment

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

Yes, I agree. It is hacky. However I'm not really sure how to solve it in a nicer way as the only thing we can act on is the log line. Looking at the references it seems like they are not intending to fix it in logrus (especially not now since it is, according to the README, looking for a maintainer).

Any suggestions on how I could solve it in a nicer way? It's really annoying that all logs from external-dns shows up as errors, even if it's not.

@freddd freddd closed this Feb 8, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. size/S Denotes a PR that changes 10-29 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants