Documentation ¶
Index ¶
- func EventString(event *logutilpb.Event) string
- func EventToBuffer(event *logutilpb.Event, buf *bytes.Buffer)
- func Flush()
- func LogEvent(logger Logger, event *logutilpb.Event)
- func NewLoggerWriter(logger Logger) io.Writer
- func OnFlush(fn func())
- func ProtoToTime(ts *logutilpb.Time) time.Time
- func PurgeLogs()
- func TimeToProto(t time.Time) *logutilpb.Time
- type ChannelLogger
- func (cl ChannelLogger) ErrorDepth(depth int, s string)
- func (cl ChannelLogger) Errorf(format string, v ...interface{})
- func (cl ChannelLogger) InfoDepth(depth int, s string)
- func (cl ChannelLogger) Infof(format string, v ...interface{})
- func (cl ChannelLogger) Printf(format string, v ...interface{})
- func (cl ChannelLogger) WarningDepth(depth int, s string)
- func (cl ChannelLogger) Warningf(format string, v ...interface{})
- type ConsoleLogger
- func (cl *ConsoleLogger) ErrorDepth(depth int, s string)
- func (cl *ConsoleLogger) Errorf(format string, v ...interface{})
- func (cl *ConsoleLogger) InfoDepth(depth int, s string)
- func (cl *ConsoleLogger) Infof(format string, v ...interface{})
- func (cl *ConsoleLogger) Printf(format string, v ...interface{})
- func (cl *ConsoleLogger) WarningDepth(depth int, s string)
- func (cl *ConsoleLogger) Warningf(format string, v ...interface{})
- type Logger
- type LoggerWriter
- type MemoryLogger
- func (ml *MemoryLogger) ErrorDepth(depth int, s string)
- func (ml *MemoryLogger) Errorf(format string, v ...interface{})
- func (ml *MemoryLogger) InfoDepth(depth int, s string)
- func (ml *MemoryLogger) Infof(format string, v ...interface{})
- func (ml *MemoryLogger) Printf(format string, v ...interface{})
- func (ml *MemoryLogger) String() string
- func (ml *MemoryLogger) WarningDepth(depth int, s string)
- func (ml *MemoryLogger) Warningf(format string, v ...interface{})
- type TeeLogger
- func (tl *TeeLogger) ErrorDepth(depth int, s string)
- func (tl *TeeLogger) Errorf(format string, v ...interface{})
- func (tl *TeeLogger) InfoDepth(depth int, s string)
- func (tl *TeeLogger) Infof(format string, v ...interface{})
- func (tl *TeeLogger) Printf(format string, v ...interface{})
- func (tl *TeeLogger) WarningDepth(depth int, s string)
- func (tl *TeeLogger) Warningf(format string, v ...interface{})
- type ThrottledLogger
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func EventString ¶
EventString returns the line in one string
func EventToBuffer ¶
EventToBuffer formats an individual Event into a buffer, without the final '\n'
func Flush ¶
func Flush()
Flush calls the functions registered through OnFlush() and waits for them.
Programs that use servenv.Run*() will invoke Flush() automatically at shutdown. Other programs should defer logutil.Flush() at the beginning of main().
Concurrent calls to Flush are serialized.
func LogEvent ¶
LogEvent sends an event to a Logger, using the level specified in the event. The event struct is converted to a string with EventString().
func NewLoggerWriter ¶
NewLoggerWriter returns an io.Writer on top of the logger
func OnFlush ¶
func OnFlush(fn func())
OnFlush registers a function to be called when Flush() is invoked.
func ProtoToTime ¶
ProtoToTime converts a logutilpb.Time to a time.Time.
A nil pointer is like the empty timestamp.
Types ¶
type ChannelLogger ¶
ChannelLogger is a Logger that sends the logging events through a channel for consumption.
func NewChannelLogger ¶
func NewChannelLogger(size int) ChannelLogger
NewChannelLogger returns a ChannelLogger fo the given size
func (ChannelLogger) ErrorDepth ¶
func (cl ChannelLogger) ErrorDepth(depth int, s string)
ErrorDepth is part of the Logger interface
func (ChannelLogger) Errorf ¶
func (cl ChannelLogger) Errorf(format string, v ...interface{})
Errorf is part of the Logger interface.
func (ChannelLogger) InfoDepth ¶
func (cl ChannelLogger) InfoDepth(depth int, s string)
InfoDepth is part of the Logger interface.
func (ChannelLogger) Infof ¶
func (cl ChannelLogger) Infof(format string, v ...interface{})
Infof is part of the Logger interface.
func (ChannelLogger) Printf ¶
func (cl ChannelLogger) Printf(format string, v ...interface{})
Printf is part of the Logger interface.
func (ChannelLogger) WarningDepth ¶
func (cl ChannelLogger) WarningDepth(depth int, s string)
WarningDepth is part of the Logger interface
func (ChannelLogger) Warningf ¶
func (cl ChannelLogger) Warningf(format string, v ...interface{})
Warningf is part of the Logger interface.
type ConsoleLogger ¶
type ConsoleLogger struct{}
ConsoleLogger is a Logger that uses glog directly to log, at the right level.
Note that methods on ConsoleLogger must use pointer receivers, because otherwise an autogenerated conversion method will be inserted in the call stack when ConsoleLogger is used via TeeLogger, making the log depth incorrect.
func NewConsoleLogger ¶
func NewConsoleLogger() *ConsoleLogger
NewConsoleLogger returns a simple ConsoleLogger.
func (*ConsoleLogger) ErrorDepth ¶
func (cl *ConsoleLogger) ErrorDepth(depth int, s string)
ErrorDepth is part of the Logger interface.
func (*ConsoleLogger) Errorf ¶
func (cl *ConsoleLogger) Errorf(format string, v ...interface{})
Errorf is part of the Logger interface
func (*ConsoleLogger) InfoDepth ¶
func (cl *ConsoleLogger) InfoDepth(depth int, s string)
InfoDepth is part of the Logger interface.
func (*ConsoleLogger) Infof ¶
func (cl *ConsoleLogger) Infof(format string, v ...interface{})
Infof is part of the Logger interface
func (*ConsoleLogger) Printf ¶
func (cl *ConsoleLogger) Printf(format string, v ...interface{})
Printf is part of the Logger interface
func (*ConsoleLogger) WarningDepth ¶
func (cl *ConsoleLogger) WarningDepth(depth int, s string)
WarningDepth is part of the Logger interface.
func (*ConsoleLogger) Warningf ¶
func (cl *ConsoleLogger) Warningf(format string, v ...interface{})
Warningf is part of the Logger interface
type Logger ¶
type Logger interface { // Infof logs at INFO level. A newline is appended if missing. Infof(format string, v ...interface{}) // Warningf logs at WARNING level. A newline is appended if missing. Warningf(format string, v ...interface{}) // Errorf logs at ERROR level. A newline is appended if missing. Errorf(format string, v ...interface{}) // Printf will just display information on stdout when possible. // No newline is appended. Printf(format string, v ...interface{}) // InfoDepth allows call frame depth to be adjusted when logging to INFO. InfoDepth(depth int, s string) // WarningDepth allows call frame depth to be adjusted when logging to WARNING. WarningDepth(depth int, s string) // ErrorDepth allows call frame depth to be adjusted when logging to ERROR. ErrorDepth(depth int, s string) }
Logger defines the interface to use for our logging interface. All methods should be thread safe (i.e. multiple go routines can call these methods simultaneously).
type LoggerWriter ¶
type LoggerWriter struct {
// contains filtered or unexported fields
}
LoggerWriter is an adapter that implements the io.Writer interface.
type MemoryLogger ¶
MemoryLogger keeps the logging events in memory. All protected by a mutex.
func NewMemoryLogger ¶
func NewMemoryLogger() *MemoryLogger
NewMemoryLogger returns a new MemoryLogger
func (*MemoryLogger) ErrorDepth ¶
func (ml *MemoryLogger) ErrorDepth(depth int, s string)
ErrorDepth is part of the Logger interface.
func (*MemoryLogger) Errorf ¶
func (ml *MemoryLogger) Errorf(format string, v ...interface{})
Errorf is part of the Logger interface.
func (*MemoryLogger) InfoDepth ¶
func (ml *MemoryLogger) InfoDepth(depth int, s string)
InfoDepth is part of the Logger interface.
func (*MemoryLogger) Infof ¶
func (ml *MemoryLogger) Infof(format string, v ...interface{})
Infof is part of the Logger interface.
func (*MemoryLogger) Printf ¶
func (ml *MemoryLogger) Printf(format string, v ...interface{})
Printf is part of the Logger interface.
func (*MemoryLogger) String ¶
func (ml *MemoryLogger) String() string
String returns all the lines in one String, separated by '\n'
func (*MemoryLogger) WarningDepth ¶
func (ml *MemoryLogger) WarningDepth(depth int, s string)
WarningDepth is part of the Logger interface.
func (*MemoryLogger) Warningf ¶
func (ml *MemoryLogger) Warningf(format string, v ...interface{})
Warningf is part of the Logger interface.
type TeeLogger ¶
type TeeLogger struct {
One, Two Logger
}
TeeLogger is a Logger that sends its logs to two underlying logger
func NewTeeLogger ¶
NewTeeLogger returns a logger that sends its logs to both loggers
func (*TeeLogger) ErrorDepth ¶
ErrorDepth is part of the Logger interface
func (*TeeLogger) WarningDepth ¶
WarningDepth is part of the Logger interface
type ThrottledLogger ¶
type ThrottledLogger struct {
// contains filtered or unexported fields
}
ThrottledLogger will allow logging of messages but won't spam the logs.
func NewThrottledLogger ¶
func NewThrottledLogger(name string, maxInterval time.Duration) *ThrottledLogger
NewThrottledLogger will create a ThrottledLogger with the given name and throttling interval.
func (*ThrottledLogger) Errorf ¶
func (tl *ThrottledLogger) Errorf(format string, v ...interface{})
Errorf logs an error if not throttled.
func (*ThrottledLogger) Infof ¶
func (tl *ThrottledLogger) Infof(format string, v ...interface{})
Infof logs an info if not throttled.
func (*ThrottledLogger) Warningf ¶
func (tl *ThrottledLogger) Warningf(format string, v ...interface{})
Warningf logs a warning if not throttled.