-
Notifications
You must be signed in to change notification settings - Fork 127
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
7137b23
commit 550db51
Showing
1 changed file
with
39 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
package event | ||
|
||
import ( | ||
"k8s.io/apimachinery/pkg/runtime" | ||
"k8s.io/client-go/tools/record" | ||
) | ||
|
||
type Logger interface { | ||
Info(obj runtime.Object, message string) | ||
Infof(obj runtime.Object, messagefmt string, args ...interface{}) | ||
Error(obj runtime.Object, message string) | ||
Errorf(obj runtime.Object, messagefmt string, args ...interface{}) | ||
} | ||
|
||
type logger struct { | ||
recorder record.EventRecorder | ||
} | ||
|
||
func (l *logger) Info(obj runtime.Object, message string) { | ||
l.recorder.Event(obj, "Normal", "Message", message) | ||
} | ||
|
||
func (l *logger) Infof(obj runtime.Object, messagefmt string, args ...interface{}) { | ||
l.recorder.Eventf(obj, "Normal", "Message", messagefmt, args...) | ||
} | ||
|
||
func (l *logger) Error(obj runtime.Object, message string) { | ||
l.recorder.Event(obj, "Warning", "Message", message) | ||
} | ||
|
||
func (l *logger) Errorf(obj runtime.Object, messagefmt string, args ...interface{}) { | ||
l.recorder.Eventf(obj, "Warning", "Message", messagefmt, args...) | ||
} | ||
|
||
func NewLogger(recorder record.EventRecorder) Logger { | ||
return &logger{ | ||
recorder: recorder, | ||
} | ||
} |