-
Notifications
You must be signed in to change notification settings - Fork 2.6k
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
Conversation
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. |
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: If they are not already assigned, you can assign the PR to them by writing 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 |
/check-cla |
/assign @hjacobs |
|
||
// 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")) || |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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.
Fixes #772
Basically, the issue is that
logrus
by default pipes all logs tostderr
. This displays logs as being errors when they are actuallylevel=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).This example shows the
--log-splitting
flagTo verify it, you can just
cat 1.stdout
andcat 2.stderr
.References:
sirupsen/logrus#403
Azure/open-service-broker-azure#25