Documentation
¶
Index ¶
- func ParseLevel(s string) (slog.Level, error)
- func SetEntryInContext(ctx context.Context, e Entry) context.Context
- type Entry
- type Logger
- func (e Logger) Debugf(format string, args ...any)
- func (e Logger) Errorf(format string, args ...any)
- func (l *Logger) Fatalf(format string, args ...any)
- func (e Logger) Infof(format string, args ...any)
- func (l *Logger) StdLogger(level slog.Level) *stdlog.Logger
- func (e Logger) SystemErr(err error)
- func (e Logger) Warnf(format string, args ...any)
- func (e Logger) WithFields(fields map[string]any) Entry
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ParseLevel ¶ added in v0.18.0
ParseLevel converts a configured log-level string into an slog.Level. It accepts the legacy logrus level names so existing operator configuration keeps working: trace maps to debug, warning to warn, and fatal/panic to error.
Types ¶
type Entry ¶
type Entry interface {
// Basic Logging Operation
Debugf(format string, args ...any)
Infof(format string, args ...any)
Warnf(format string, args ...any)
Errorf(format string, args ...any)
// Attach contextual information to the logging entry
WithFields(fields map[string]any) Entry
// SystemErr is a method that disects the error
// and logs the appropriate level and fields for it.
SystemErr(err error)
}
Entry is an abstraction to the Logger and the underlying slog logger so that *Logger always creates an Entry copy which ensures no Fields are being overwritten.
func EntryFromContext ¶ added in v0.2.0
EntryFromContext returns an Entry that has been stored in the request context. If there is no value for the key or the type assertion fails, it returns a new entry from the provided logger.
type Logger ¶
type Logger struct {
// contains filtered or unexported fields
}
Logger is the main struct that any athens internal service should use to communicate things.
func New ¶
New constructs a new logger based on the environment and the cloud platform it is running on.
func NewWithOutput ¶ added in v0.18.0
NewWithOutput is New but writes to the given io.Writer instead of stdout. It is primarily useful for tests that need to capture log output.
func NoOpLogger ¶ added in v0.2.0
func NoOpLogger() *Logger
NoOpLogger provides a Logger that does nothing.
func (*Logger) Fatalf ¶ added in v0.18.0
Fatalf logs at the error level and then exits the process. slog has no fatal level, so this preserves logrus.Fatal's exit-after-logging behavior.
func (*Logger) StdLogger ¶ added in v0.18.0
StdLogger returns a *log.Logger that routes through this logger's handler at the given level. Used to redirect output from the standard library logger.