Documentation ¶
Index ¶
- Constants
- Variables
- func AddHook(hook logrus.Hook)
- func Configure(ctx context.Context, settings *Settings) (context.Context, error)
- func ContextWithLogger(ctx context.Context, entry *logrus.Entry) context.Context
- func CorrelationIDForRequest(request *http.Request) string
- func CorrelationIDFromContext(ctx context.Context) string
- func DefaultLogger() *logrus.Entry
- func ForContext(ctx context.Context) *logrus.Entry
- func RegisterFormatter(name string, formatter logrus.Formatter) error
- type KibanaFormatter
- type Settings
Constants ¶
const ( // FieldComponentName is the key of the component field in the log message. FieldComponentName = "component" // FieldCorrelationID is the key of the correlation id field in the log message. FieldCorrelationID = "correlation_id" )
Variables ¶
var ( // C is an alias for ForContext C = ForContext // D is an alias for DefaultLogger D = DefaultLogger )
var CorrelationIDHeaders = []string{"X-CorrelationID", "X-Correlation-ID", "X-ForRequest-ID", "X-Request-ID", "X-Vcap-Request-Id", "X-Broker-API-Request-Identity"}
CorrelationIDHeaders are the headers whose values will be taken as a correlation id for incoming requests The first one will be set on outgoing requests
Functions ¶
func ContextWithLogger ¶
ContextWithLogger returns a new context with the provided logger.
func CorrelationIDForRequest ¶
CorrelationIDForRequest returns checks the http headers for any of the supported correlation id headers. The first that matches is taken as the correlation id. If none exists a new one is generated.
func CorrelationIDFromContext ¶ added in v0.5.0
CorrelationIDFromContext returns the correlation id associated with the context logger or empty string if none exists
func DefaultLogger ¶ added in v0.18.7
DefaultLogger returns the default logger
func ForContext ¶
ForContext retrieves the current logger from the context.
Types ¶
type KibanaFormatter ¶ added in v0.5.0
type KibanaFormatter struct { }
KibanaFormatter is a logrus formatter that formats an entry for Kibana
type Settings ¶
type Settings struct { Level string `description:"minimum level for log messages" json:"level,omitempty"` Format string `description:"format of log messages. Allowed values - text, json" json:"format,omitempty"` Output string `description:"output for the logs. Allowed values - /dev/stdout, /dev/stderr, ginkgowriter" json:"output,omitempty"` }
Settings type to be loaded from the environment
func Configuration ¶ added in v0.5.0
func Configuration() Settings
Configuration returns the logger settings
func DefaultSettings ¶
func DefaultSettings() *Settings
DefaultSettings returns default values for Log settings