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:
		| @@ -60,7 +60,7 @@ func EventString(ev *auditinternal.Event) string { | |||||||
| 		ip = ev.SourceIPs[0] | 		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) | 		ev.Timestamp.Format(time.RFC3339Nano), ev.AuditID, ev.Stage, ip, ev.Verb, username, groups, asuser, asgroups, namespace, ev.RequestURI, response) | ||||||
| } | } | ||||||
|  |  | ||||||
|   | |||||||
| @@ -72,7 +72,7 @@ func ObservePolicyLevel(level auditinternal.Level) { | |||||||
|  |  | ||||||
| // HandlePluginError handles an error that occurred in an audit plugin. This method should only be | // 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 | // 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) { | func HandlePluginError(plugin string, err error, impacted ...*auditinternal.Event) { | ||||||
| 	// Count the error. | 	// Count the error. | ||||||
| 	errorCounter.WithLabelValues(plugin).Add(float64(len(impacted))) | 	errorCounter.WithLabelValues(plugin).Add(float64(len(impacted))) | ||||||
|   | |||||||
| @@ -47,7 +47,7 @@ func (b *backend) ProcessEvents(events ...*auditinternal.Event) { | |||||||
|  |  | ||||||
| func (b *backend) logEvent(ev *auditinternal.Event) { | func (b *backend) logEvent(ev *auditinternal.Event) { | ||||||
| 	line := audit.EventString(ev) | 	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) | 		audit.HandlePluginError("log", err, ev) | ||||||
| 	} | 	} | ||||||
| } | } | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user
	 Kubernetes Submit Queue
					Kubernetes Submit Queue