Documentation ¶
Overview ¶
Package logadapter provides an adapter to the go-kit log.Logger interface.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func InitLogging ¶ added in v0.4.0
InitLogging initializes a logrus logger to send things to stackdriver.
Types ¶
type Context ¶ added in v0.4.0
type Context struct { Data map[string]interface{} `json:"data,omitempty"` ReportLocation *ReportLocation `json:"reportLocation,omitempty"` HTTPRequest *HTTPRequest `json:"httpRequest,omitempty"` PubSubRequest map[string]interface{} `json:"pubSubRequest,omitempty"` GRPCRequest map[string]interface{} `json:"grpcRequest,omitempty"` }
Context is sent with every message to stackdriver.
type Entry ¶ added in v0.4.0
type Entry struct { LogName string `json:"logName,omitempty"` Timestamp string `json:"timestamp,omitempty"` Trace string `json:"trace,omitempty"` ServiceContext *ServiceContext `json:"serviceContext,omitempty"` Message string `json:"message,omitempty"` Severity severity `json:"severity,omitempty"` Context *Context `json:"context,omitempty"` SourceLocation *ReportLocation `json:"sourceLocation,omitempty"` }
Entry stores a log entry.
type Formatter ¶
type Formatter struct { Service string Version string ProjectID string StackSkip []string SkipTimestamp bool RegexSkip string }
Formatter implements Stackdriver formatting for logrus.
func NewFormatter ¶
NewFormatter returns a new Formatter.
type HTTPRequest ¶ added in v0.4.0
type HTTPRequest struct { RequestMethod string `json:"requestMethod,omitempty"` RequestURL string `json:"requestUrl,omitempty"` RequestSize string `json:"requestSize,omitempty"` Status string `json:"status,omitempty"` ResponseSize string `json:"responseSize,omitempty"` UserAgent string `json:"userAgent,omitempty"` RemoteIP string `json:"remoteIp,omitempty"` ServerIP string `json:"serverIp,omitempty"` Referer string `json:"referer,omitempty"` Latency string `json:"latency,omitempty"` CacheLookup bool `json:"cacheLookup,omitempty"` CacheHit bool `json:"cacheHit,omitempty"` CacheValidatedWithOriginServer bool `json:"cacheValidatedWithOriginServer,omitempty"` CacheFillBytes string `json:"cacheFillBytes,omitempty"` Protocol string `json:"protocol,omitempty"` }
HTTPRequest defines details of a request and response to append to a log.
type LogrusGoKitLogger ¶ added in v0.4.0
type LogrusGoKitLogger struct {
// contains filtered or unexported fields
}
LogrusGoKitLogger is a gokit-compatible wrapper for logrus.LogrusGoKitLogger
func InitLogrusGoKitLogger ¶ added in v0.4.0
func InitLogrusGoKitLogger(w io.Writer, opts ...Option) *LogrusGoKitLogger
InitLogrusGoKitLogger initializes a go kit logger to send things to stackdriver.
func NewLogrusGoKitLogger ¶ added in v0.4.0
func NewLogrusGoKitLogger(logger logrusLogger) *LogrusGoKitLogger
NewLogrusGoKitLogger creates a gokit-compatible logger
func (LogrusGoKitLogger) Log ¶ added in v0.4.0
func (l LogrusGoKitLogger) Log(keyvals ...interface{}) error
Log implements the fundamental Logger interface
type Option ¶
type Option func(*Formatter)
Option lets you configure the Formatter.
func WithProjectID ¶ added in v0.4.0
WithProjectID makes sure all entries have your Project information.
func WithRegexSkip ¶ added in v0.4.0
WithRegexSkip lets you configure which functions or packages should be skipped for locating the error.
func WithService ¶
WithService lets you configure the service name used for error reporting.
func WithSkipTimestamp ¶ added in v0.4.0
func WithSkipTimestamp() Option
WithSkipTimestamp lets you avoid setting the timestamp
func WithStackSkip ¶
WithStackSkip lets you configure which packages should be skipped for locating the error.
func WithVersion ¶
WithVersion lets you configure the service version used for error reporting.
type ReportLocation ¶ added in v0.4.0
type ReportLocation struct { FilePath string `json:"file,omitempty"` LineNumber int `json:"line,omitempty"` FunctionName string `json:"function,omitempty"` }
ReportLocation is the information about where an error occurred.
type ServiceContext ¶ added in v0.4.0
type ServiceContext struct { Service string `json:"service,omitempty"` Version string `json:"version,omitempty"` }
ServiceContext provides the data about the service we are sending to Google.