)
// LogFunc is a helper type to reduce typing.
-type LogFunc func(level safcm.LogLevel, format string, a ...interface{})
+type LogFunc func(level safcm.LogLevel, msg string)
-type Logger interface {
- Verbosef(format string, a ...interface{})
- Debugf(format string, a ...interface{})
- Debug2f(format string, a ...interface{})
+type Logger struct {
+ fun LogFunc
}
-type PrefixLogger struct {
- fun LogFunc
- prefix string
-}
-
-func NewLogger(prefix string, fun LogFunc) *PrefixLogger {
- return &PrefixLogger{
- fun: fun,
- prefix: prefix,
+func NewLogger(fun LogFunc) *Logger {
+ return &Logger{
+ fun: fun,
}
}
-func (l *PrefixLogger) Verbosef(format string, a ...interface{}) {
+func (l *Logger) Verbosef(format string, a ...interface{}) {
l.log(safcm.LogVerbose, format, a...)
}
-func (l *PrefixLogger) Debugf(format string, a ...interface{}) {
+func (l *Logger) Debugf(format string, a ...interface{}) {
l.log(safcm.LogDebug, format, a...)
}
-func (l *PrefixLogger) Debug2f(format string, a ...interface{}) {
+func (l *Logger) Debug2f(format string, a ...interface{}) {
l.log(safcm.LogDebug2, format, a...)
}
-func (l *PrefixLogger) log(level safcm.LogLevel,
+func (l *Logger) log(level safcm.LogLevel,
format string, a ...interface{}) {
- l.fun(level, "%s %s", l.prefix, fmt.Sprintf(format, a...))
+ l.fun(level, fmt.Sprintf(format, a...))
}