Documentation ¶
Index ¶
- Constants
- Variables
- func AddHook(hook logrus.Hook)
- func Configure(ctx context.Context, settings *Settings) context.Context
- func ContextWithLogger(ctx context.Context, entry *logrus.Entry) context.Context
- func CorrelationIDForRequest(request *http.Request) string
- func Default() *logrus.Entry
- func ForContext(ctx context.Context) *logrus.Entry
- func RegisterFormatter(name string, formatter logrus.Formatter) error
- type Settings
Constants ¶
View Source
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 ¶
View Source
var ( // C is an alias for ForContext C = ForContext // D is an alias for Default D = Default )
View Source
var CorrelationIDHeaders = []string{"X-Correlation-ID", "X-CorrelationID", "X-ForRequest-ID", "X-Request-ID"}
CorrelationIDHeaders are the headers whose values will be taken as a correlation id for incoming 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 ForContext ¶
ForContext retrieves the current logger from the context.
Types ¶
type Settings ¶
Settings type to be loaded from the environment
func DefaultSettings ¶
func DefaultSettings() *Settings
DefaultSettings returns default values for Log settings
Click to show internal directories.
Click to hide internal directories.