Merge pull request #46929 from CaoShuFeng/extra_newline

Automatic merge from submit-queue (batch tested with PRs 46929, 47391, 47399, 47428, 47274)

Remove empty lines from log

Everything() returns a new line end with "\n", it's not necessary
to add another one.
**Release note**:

```
NONE
```
This commit is contained in:
Kubernetes Submit Queue 2017-06-13 10:52:06 -07:00 committed by GitHub
commit e58bc88c55
3 changed files with 3 additions and 3 deletions

View File

@ -60,7 +60,7 @@ func EventString(ev *auditinternal.Event) string {
ip = ev.SourceIPs[0]
}
return fmt.Sprintf("%s AUDIT: id=%q stage=%q ip=%q method=%q user=%q groups=%q as=%q asgroups=%q namespace=%q uri=%q response=\"%s\"\n",
return fmt.Sprintf("%s AUDIT: id=%q stage=%q ip=%q method=%q user=%q groups=%q as=%q asgroups=%q namespace=%q uri=%q response=\"%s\"",
ev.Timestamp.Format(time.RFC3339Nano), ev.AuditID, ev.Stage, ip, ev.Verb, username, groups, asuser, asgroups, namespace, ev.RequestURI, response)
}

View File

@ -72,7 +72,7 @@ func ObservePolicyLevel(level auditinternal.Level) {
// HandlePluginError handles an error that occurred in an audit plugin. This method should only be
// used if the error may have prevented the audit event from being properly recorded. The events are
// modified.
// logged to the debug log.
func HandlePluginError(plugin string, err error, impacted ...*auditinternal.Event) {
// Count the error.
errorCounter.WithLabelValues(plugin).Add(float64(len(impacted)))

View File

@ -47,7 +47,7 @@ func (b *backend) ProcessEvents(events ...*auditinternal.Event) {
func (b *backend) logEvent(ev *auditinternal.Event) {
line := audit.EventString(ev)
if _, err := fmt.Fprint(b.out, line); err != nil {
if _, err := fmt.Fprintln(b.out, line); err != nil {
audit.HandlePluginError("log", err, ev)
}
}