Documentation
¶
Index ¶
- func Ctx(ctx context.Context) *zerolog.Logger
- func Debug() *zerolog.Event
- func Error() *zerolog.Event
- func Fatal() *zerolog.Event
- func Info() *zerolog.Event
- func Log() *zerolog.Event
- func Panic() *zerolog.Event
- func Register(ctx context.Context, opts *Options) error
- func Shutdown(ctx context.Context) error
- func Trace() *zerolog.Event
- func Warn() *zerolog.Event
- func WithFields(ctx context.Context, fields map[string]interface{}) *zerolog.Logger
- type Logger
- type Option
- type Options
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Ctx ¶
Ctx retrieves the zerolog.Logger from the provided context.
This function extracts the zerolog.Logger instance associated with the given context. It is useful for logging within the context of a request or operation.
Parameters: - ctx context.Context: The context from which to retrieve the logger.
Returns: - *zerolog.Logger: The logger associated with the context.
func WithFields ¶ added in v0.2.0
WithFields adds fields to the zerolog.Logger in the provided context.
This function retrieves the zerolog.Logger from the context, adds the specified fields to the logger's context, and returns the updated logger. It is useful for adding contextual information to logs.
Parameters: - ctx context.Context: The context from which to retrieve the logger. - fields map[string]any: The fields to add to the logger's context.
Returns: - *zerolog.Logger: The updated logger with the added fields.
Types ¶
type Logger ¶
type Logger struct {
// contains filtered or unexported fields
}
func (*Logger) Provider ¶
func (l *Logger) Provider() *log.LoggerProvider
type Option ¶
type Option interface {
ApplyLoggerOption(*Options)
}
Option defines an interface for applying meter options.
func WithCommonOptions ¶
func WithEnabled ¶
WithEnabled returns an Option that sets the enabled state of the meter. This function is a convenient way to enable or disable the meter functionality.
func WithExportInterval ¶
WithExportInterval returns an Option that sets the read interval of the meter. This function is a convenient way to specify how often the meter reads data.
func WithLevel ¶
WithLevel returns an Option that sets the log level of the meter. This function is a convenient way to specify the log level for the meter.
func WithWriter ¶
WithWriter returns an Option that sets the writer for the meter. This function is a convenient way to specify the writer to which logs are written.
type Options ¶
type Options struct { Enabled bool // Enabled specifies whether the meter is enabled. ExportInterval time.Duration // ExportInterval specifies the interval at which the meter exports data. Level level.Level // Level specifies the log level of the meter. Writer io.Writer // Writer specifies the writer to write logs to. }
Options holds configuration options for a meter.