Documentation ¶
Overview ¶
Package logger provides a logger that logs to Google Cloud Logging. It's a thin wrapper around golang/cloud/logging package.
Index ¶
- Constants
- type Logger
- func (l *Logger) Critical(payload interface{})
- func (l *Logger) Criticalf(format string, args ...interface{})
- func (l *Logger) Debug(payload interface{})
- func (l *Logger) Debugf(format string, args ...interface{})
- func (l *Logger) Error(payload interface{})
- func (l *Logger) Errorf(format string, args ...interface{})
- func (l *Logger) Info(payload interface{})
- func (l *Logger) Infof(format string, args ...interface{})
- func (l *Logger) Warning(payload interface{})
- func (l *Logger) Warningf(format string, args ...interface{})
Constants ¶
const (
// MaxLogEntrySize Max value of each log entry size
MaxLogEntrySize = 4096
)
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Logger ¶
type Logger struct {
// contains filtered or unexported fields
}
Logger implements a logger that logs messages to Google Cloud Logging. It provides a suite of methods where each method correponds to a specific logging.Level, e.g. Error(paylod interface{}). Each method takes a payload that has to either be a JSON-encodable object, a string or a []byte slice (all other types of payload will result in error).
It falls back to logging through the traditional logger if:
- Not running on GCE,
- Logging client is uninitialized (e.g. for testing),
- Logging to cloud fails for some reason.
Logger{} is a valid object that will log through the traditional logger.
func (*Logger) Critical ¶
func (l *Logger) Critical(payload interface{})
Critical logs messages with logging level set to "Critical" and exits the process with error status. The buffer is flushed before exiting.
func (*Logger) Criticalf ¶
Criticalf logs formatted text messages with logging level "Critical" and exits the process with error status. The buffer is flushed before exiting.
func (*Logger) Debug ¶
func (l *Logger) Debug(payload interface{})
Debug logs messages with logging level set to "Debug".
func (*Logger) Error ¶
func (l *Logger) Error(payload interface{})
Error logs messages with logging level set to "Error".
func (*Logger) Info ¶
func (l *Logger) Info(payload interface{})
Info logs messages with logging level set to "Info".