Documentation
¶
Index ¶
- Constants
- func AddLoggerToContext(ctx context.Context, logger Logger) context.Context
- func RequestIDFromContext(ctx context.Context) (string, bool)
- func WithClusterID(ctx context.Context, id string) context.Context
- func WithOrgID(ctx context.Context, id string) context.Context
- func WithRequestID(ctx context.Context, id string) context.Context
- func WithUserID(ctx context.Context, id string) context.Context
- type Logger
Constants ¶
View Source
const ( FieldRequestID = "request_id" FieldUserID = "user_id" FieldOrgID = "org_id" FieldClusterID = "cluster_id" FieldStackID = "stack_id" FieldReleaseID = "release_id" FieldResource = "resource" FieldComponent = "component" )
Field name constants for structured logging. Callers attach these via WithField/WithFields instead of interpolating IDs into message strings.
Variables ¶
This section is empty.
Functions ¶
func AddLoggerToContext ¶
func WithRequestID ¶
WithRequestID stamps a request/correlation ID onto the context so every context-aware log call made downstream carries it as a structured field.
Types ¶
type Logger ¶
type Logger interface {
SetLevel(level logrus.Level) Logger
GetLevel() logrus.Level
// WithField returns a child logger that attaches the given key/value to
// every subsequent log entry. The parent is left unchanged.
WithField(key string, value interface{}) Logger
// WithFields returns a child logger that attaches all the given fields to
// every subsequent log entry. The parent is left unchanged.
WithFields(fields map[string]interface{}) Logger
DebugEnabled() bool
// InfoEnabled returns true if the information level is enabled.
InfoEnabled() bool
// WarnEnabled returns true if the warning level is enabled.
WarnEnabled() bool
// ErrorEnabled returns true if the error level is enabled.
ErrorEnabled() bool
// Debug sends to the log a debug message formatted using the fmt.Sprintf function and the
// given format and arguments.
Debug(ctx context.Context, format string, args ...interface{})
// Info sends to the log an information message formatted using the fmt.Sprintf function and
// the given format and arguments.
Infof(format string, args ...interface{})
Info(ctx context.Context, format string, args ...interface{})
// Warn sends to the log a warning message formatted using the fmt.Sprintf function and the
// given format and arguments.
Warn(ctx context.Context, format string, args ...interface{})
// Error sends to the log an error message formatted using the fmt.Sprintf function and
// the given format and arguments.
Error(ctx context.Context, format string, args ...interface{})
Errorf(format string, args ...interface{})
Debugf(format string, args ...interface{})
Fatalf(format string, args ...interface{})
Warnf(format string, args ...interface{})
// Fatal sends to the log an error message formatted using the fmt.Sprintf function and
// the given format and arguments; and then executes an os.Exit(1)
// Fatal level is always enabled
Fatal(ctx context.Context, format string, args ...interface{})
}
func GetLoggerFromContext ¶
func NewLogger ¶
func NewLogger() Logger
NewLogger creates a new logger instance with standard configuration
func NewLoggerWithDebug ¶
Click to show internal directories.
Click to hide internal directories.