Documentation ¶
Overview ¶
Package applogger define a set of simple logger interfaces that can be implement by the libraries client and that it should be used in all devo-go libraries
Some implementations are added here like NoLogAppLogger (no log logger) and WriterAppLogger log that uses a provided Writer as destination of messages.
Index ¶
- func LevelComp(l, o Level) int
- func LevelString(l Level) string
- type AppLogger
- type Level
- type NoLogAppLogger
- func (*NoLogAppLogger) Debug(a ...interface{})
- func (*NoLogAppLogger) Debugf(format string, a ...interface{})
- func (*NoLogAppLogger) Error(a ...interface{})
- func (*NoLogAppLogger) Errorf(format string, a ...interface{})
- func (*NoLogAppLogger) Fatal(a ...interface{})
- func (*NoLogAppLogger) Fatalf(format string, a ...interface{})
- func (*NoLogAppLogger) Info(a ...interface{})
- func (*NoLogAppLogger) Infof(format string, a ...interface{})
- func (*NoLogAppLogger) IsLevelEnabled(l Level) bool
- func (*NoLogAppLogger) Log(l Level, a ...interface{})
- func (*NoLogAppLogger) Logf(l Level, format string, a ...interface{})
- func (*NoLogAppLogger) Warn(a ...interface{})
- func (*NoLogAppLogger) Warnf(format string, a ...interface{})
- type SimpleAppLogger
- type WriterAppLogger
- func (w *WriterAppLogger) Debug(a ...interface{})
- func (w *WriterAppLogger) Debugf(format string, a ...interface{})
- func (w *WriterAppLogger) Error(a ...interface{})
- func (w *WriterAppLogger) Errorf(format string, a ...interface{})
- func (w *WriterAppLogger) Fatal(a ...interface{})
- func (w *WriterAppLogger) Fatalf(format string, a ...interface{})
- func (w *WriterAppLogger) Info(a ...interface{})
- func (w *WriterAppLogger) Infof(format string, a ...interface{})
- func (w *WriterAppLogger) IsLevelEnabled(l Level) bool
- func (w *WriterAppLogger) Log(l Level, a ...interface{})
- func (w *WriterAppLogger) Logf(l Level, format string, a ...interface{})
- func (w *WriterAppLogger) Warn(a ...interface{})
- func (w *WriterAppLogger) Warnf(format string, a ...interface{})
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func LevelComp ¶
LevelComp returns: 0 if l is equal to o, 1 if l is greater than o or -1 if l is less than o
func LevelString ¶
LevelString returns the string value of the Level l
Types ¶
type AppLogger ¶
type AppLogger interface { SimpleAppLogger Debug(a ...interface{}) Debugf(format string, a ...interface{}) Info(a ...interface{}) Infof(format string, a ...interface{}) Warn(a ...interface{}) Warnf(format string, a ...interface{}) Error(a ...interface{}) Errorf(format string, a ...interface{}) Fatal(a ...interface{}) Fatalf(format string, a ...interface{}) }
AppLogger defines the Logger interface
type NoLogAppLogger ¶
type NoLogAppLogger struct{}
NoLogAppLogger is a dummy implementation of AppLogger that does not do nothing
Example ¶
lg := &NoLogAppLogger{} i := 0 lg.Debug("Debug called", "i", i) i++ lg.Debugf("Debugf called, i: %d", i) i++ lg.Info("Info called", "i", i) i++ lg.Infof("Infof called, i: %d", i) i++ lg.Warn("Warn called", "i", i) i++ lg.Warnf("Warnf called, i: %d", i) i++ lg.Error("Error called", "i", i) i++ lg.Errorf("Errorf called, i: %d", i) i++ lg.Fatal("Fatal called", "i", i) i++ lg.Fatalf("Fatalf called, i: %d", i) lg.Log(FATAL, "Log with FATAL level called", "i", i) i++ lg.Logf(FATAL, "Logf with FATAL level called, i: %d", i) for i := FATAL; i <= DEBUG; i++ { fmt.Println("Is", LevelString(i), "enabled?:", lg.IsLevelEnabled(i)) }
Output: Is FATAL enabled?: false Is ERROR enabled?: false Is WARN enabled?: false Is INFO enabled?: false Is DEBUG enabled?: false
func (*NoLogAppLogger) Debug ¶
func (*NoLogAppLogger) Debug(a ...interface{})
Debug is the implementation of Debug in AppLogger interface for NoLogAppLogger
func (*NoLogAppLogger) Debugf ¶
func (*NoLogAppLogger) Debugf(format string, a ...interface{})
Debugf is the implementation of Debugf in AppLogger interface for NoLogAppLogger
func (*NoLogAppLogger) Error ¶
func (*NoLogAppLogger) Error(a ...interface{})
Error is the implementation of Error in AppLogger interface for NoLogAppLogger
func (*NoLogAppLogger) Errorf ¶
func (*NoLogAppLogger) Errorf(format string, a ...interface{})
Errorf is the implementation of Errorf in AppLogger interface for NoLogAppLogger
func (*NoLogAppLogger) Fatal ¶
func (*NoLogAppLogger) Fatal(a ...interface{})
Fatal is the implementation of Fatal in AppLogger interface for NoLogAppLogger
func (*NoLogAppLogger) Fatalf ¶
func (*NoLogAppLogger) Fatalf(format string, a ...interface{})
Fatalf is the implementation of Fatalf in AppLogger interface for NoLogAppLogger
func (*NoLogAppLogger) Info ¶
func (*NoLogAppLogger) Info(a ...interface{})
Info is the implementation of Info in AppLogger interface for NoLogAppLogger
func (*NoLogAppLogger) Infof ¶
func (*NoLogAppLogger) Infof(format string, a ...interface{})
Infof is the implementation of Infof in AppLogger interface for NoLogAppLogger
func (*NoLogAppLogger) IsLevelEnabled ¶
func (*NoLogAppLogger) IsLevelEnabled(l Level) bool
IsLevelEnabled is the implementation of IsLevelEnabled in AppLogger interface for NoLogAppLogger
func (*NoLogAppLogger) Log ¶
func (*NoLogAppLogger) Log(l Level, a ...interface{})
Log is the implementation of Log in AppLogger interface for NoLogAppLogger
func (*NoLogAppLogger) Logf ¶
func (*NoLogAppLogger) Logf(l Level, format string, a ...interface{})
Logf is the implementation of Logf in AppLogger interface for NoLogAppLogger
func (*NoLogAppLogger) Warn ¶
func (*NoLogAppLogger) Warn(a ...interface{})
Warn is the implementation of Warn in AppLogger interface for NoLogAppLogger
func (*NoLogAppLogger) Warnf ¶
func (*NoLogAppLogger) Warnf(format string, a ...interface{})
Warnf is the implementation of Warnf in AppLogger interface for NoLogAppLogger
type SimpleAppLogger ¶
type SimpleAppLogger interface { IsLevelEnabled(l Level) bool Log(l Level, a ...interface{}) Logf(l Level, format string, a ...interface{}) }
SimpleAppLogger defines the minium AppLogger interface
type WriterAppLogger ¶
WriterAppLogger is an implementation of AppLogger that writes messages to io.Writer
Example ¶
var buf bytes.Buffer lg := &WriterAppLogger{Writer: &buf, Level: DEBUG, AddNow: false} i := 0 lg.Debug("Debug called", "i", i) i++ lg.Debugf("Debugf called, i: %d", i) i++ lg.Info("Info called", "i", i) i++ lg.Infof("Infof called, i: %d", i) i++ lg.Warn("Warn called", "i", i) i++ lg.Warnf("Warnf called, i: %d", i) i++ lg.Error("Error called", "i", i) i++ lg.Errorf("Errorf called, i: %d", i) i++ lg.Fatal("Fatal called", "i", i) i++ lg.Fatalf("Fatalf called, i: %d", i) fmt.Print(buf.String()) for i := FATAL; i <= DEBUG; i++ { fmt.Println("Is", LevelString(i), "enabled?:", lg.IsLevelEnabled(i)) }
Output: DEBUG Debug called i 0 DEBUG Debugf called, i: 1 INFO Info called i 2 INFO Infof called, i: 3 WARN Warn called i 4 WARN Warnf called, i: 5 ERROR Error called i 6 ERROR Errorf called, i: 7 FATAL Fatal called i 8 FATAL Fatalf called, i: 9 Is FATAL enabled?: true Is ERROR enabled?: true Is WARN enabled?: true Is INFO enabled?: true Is DEBUG enabled?: true
func (*WriterAppLogger) Debug ¶
func (w *WriterAppLogger) Debug(a ...interface{})
Debug is the implementation of Debug in AppLogger interface for WriterAppLogger
func (*WriterAppLogger) Debugf ¶
func (w *WriterAppLogger) Debugf(format string, a ...interface{})
Debugf is the implementation of Debugf in AppLogger interface for WriterAppLogger
func (*WriterAppLogger) Error ¶
func (w *WriterAppLogger) Error(a ...interface{})
Error is the implementation of Error in AppLogger interface for WriterAppLogger
func (*WriterAppLogger) Errorf ¶
func (w *WriterAppLogger) Errorf(format string, a ...interface{})
Errorf is the implementation of Errorf in AppLogger interface for WriterAppLogger
func (*WriterAppLogger) Fatal ¶
func (w *WriterAppLogger) Fatal(a ...interface{})
Fatal is the implementation of Fatal in AppLogger interface for WriterAppLogger
func (*WriterAppLogger) Fatalf ¶
func (w *WriterAppLogger) Fatalf(format string, a ...interface{})
Fatalf is the implementation of Fatalf in AppLogger interface for WriterAppLogger
func (*WriterAppLogger) Info ¶
func (w *WriterAppLogger) Info(a ...interface{})
Info is the implementation of Info in AppLogger interface for WriterAppLogger
func (*WriterAppLogger) Infof ¶
func (w *WriterAppLogger) Infof(format string, a ...interface{})
Infof is the implementation of Infof in AppLogger interface for WriterAppLogger
func (*WriterAppLogger) IsLevelEnabled ¶
func (w *WriterAppLogger) IsLevelEnabled(l Level) bool
IsLevelEnabled is the implementation of IsLevelEnabled in AppLogger interface for WriterAppLogger
func (*WriterAppLogger) Log ¶
func (w *WriterAppLogger) Log(l Level, a ...interface{})
Log is the implementation of Log in AppLogger interface for WriterAppLogger
func (*WriterAppLogger) Logf ¶
func (w *WriterAppLogger) Logf(l Level, format string, a ...interface{})
Logf is the implementation of Logf in AppLogger interface for WriterAppLogger
func (*WriterAppLogger) Warn ¶
func (w *WriterAppLogger) Warn(a ...interface{})
Warn is the implementation of Warn in AppLogger interface for WriterAppLogger
func (*WriterAppLogger) Warnf ¶
func (w *WriterAppLogger) Warnf(format string, a ...interface{})
Warnf is the implementation of Warnf in AppLogger interface for WriterAppLogger