Documentation ¶
Overview ¶
Package pallet offers a clean and simple stackdriver logging interface for google services.
Grouping Logs by Request ¶
To group all the log entries written during a single HTTP request, create two Loggers, a "parent" and a "child," with different log IDs. Both should be in the same project, and have the same MonitoredResource type and labels.
- Parent entries must have HTTPRequest.Request populated. (Strictly speaking, only the URL is necessary.)
- A child entry's timestamp must be within the time interval covered by the parent request. (i.e., before the parent.Timestamp and after the parent.Timestamp - parent.HTTPRequest.Latency. This assumes the parent.Timestamp marks the end of the request.)
- The trace field must be populated in all of the entries and match exactly.
You should observe the child log entries grouped under the parent on the console. The parent entry will not inherit the severity of its children; you must update the parent severity yourself.
Index ¶
- Constants
- func DefaultMiddleware(options *Options) func(http.Handler) http.Handler
- type ErrorInvalidConfiguration
- type Logger
- func (l *Logger) Alert(v interface{})
- func (l *Logger) Alertf(format string, v ...interface{})
- func (l *Logger) Close() error
- func (l *Logger) Critical(v interface{})
- func (l *Logger) Criticalf(format string, v ...interface{})
- func (l *Logger) Debug(v interface{})
- func (l *Logger) Debugf(format string, v ...interface{})
- func (l *Logger) Emergency(v interface{})
- func (l *Logger) Emergencyf(format string, v ...interface{})
- func (l *Logger) Error(v interface{})
- func (l *Logger) Errorf(format string, v ...interface{})
- func (l *Logger) Flush() error
- func (l *Logger) Info(v interface{})
- func (l *Logger) Infof(format string, v ...interface{})
- func (l *Logger) Log(severity logging.Severity, v interface{})
- func (l *Logger) Logf(severity logging.Severity, format string, v ...interface{})
- func (l *Logger) Notice(v interface{})
- func (l *Logger) Noticef(format string, v ...interface{})
- func (l *Logger) Warning(v interface{})
- func (l *Logger) Warningf(format string, v ...interface{})
- type Options
Constants ¶
const ContextCloudTrace contextKey = "cloudTraceID"
ContextCloudTrace is the context key for response data from routes to middleware.
const ContextLoggingClient contextKey = "palletLoggingClient"
ContextLoggingClient is the context key for response data from routes to middleware.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type ErrorInvalidConfiguration ¶
type ErrorInvalidConfiguration struct {
// contains filtered or unexported fields
}
ErrorInvalidConfiguration is thrown when a missing configuration option is required.
func (ErrorInvalidConfiguration) Error ¶
func (e ErrorInvalidConfiguration) Error() string
Error returns a string, implementing the error interface.
type Logger ¶
type Logger struct { Client *logging.Client Logger *logging.Logger MonitoredResource *monitoredres.MonitoredResource TraceID string }
Logger is a standard logging client struct.
func GetLoggerFromContext ¶
GetLoggerFromContext returns the XCloudTraceContent value from the context.
func GetLoggerFromRequest ¶
GetLoggerFromRequest returns the loggnig.Client from the context.
func NewLoggerForRequest ¶
func NewLoggerForRequest(r *http.Request, options *Options, loggingOptions ...logging.LoggerOption) (*Logger, error)
NewLoggerForRequest is a helper method to create a new client
func (*Logger) Close ¶
Close closes the Logger, ensuring all logs are flushed and closing the underlying Stackdriver Logging client.
func (*Logger) Critical ¶
func (l *Logger) Critical(v interface{})
Critical calls Log with critical severity.
func (*Logger) Emergency ¶
func (l *Logger) Emergency(v interface{})
Emergency calls Log with emergency severity.
func (*Logger) Emergencyf ¶
Emergencyf calls Logf with emergency severity.
func (*Logger) Log ¶
Log logs with the given severity. v must be either a string, or something that marshals via the encoding/json package to a JSON object (and not any other type of JSON value).
func (*Logger) Logf ¶
Logf logs with the given severity. Remaining arguments are handled in the manner of fmt.Printf.
func (*Logger) Notice ¶
func (l *Logger) Notice(v interface{})
Notice calls Log with notice severity.
type Options ¶
type Options struct { ProjectID string ServiceID string VersionID string LogType string Labels map[string]string }
Options are used to configure a client.
func NewOptionSet ¶
func NewOptionSet() *Options
NewOptionSet will create a new optionset, passed to the client.