xraylog

package
v1.8.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 26, 2024 License: MIT Imports: 8 Imported by: 2

Documentation

Overview

Package xraylog implements a logger with a log level, and an interface for a custom logger. By default, the SDK logs error messages to the os.Stderr. The log level of the built in logger can be set by using either the AWS_XRAY_DEBUG_MODE or AWS_XRAY_LOG_LEVEL environment variables. If AWS_XRAY_DEBUG_MODE is set, the log level is set to the debug level. AWS_XRAY_LOG_LEVEL may be set to debug, info, warn, error or silent. This value is ignored if AWS_XRAY_DEBUG_MODE is set.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Debug

func Debug(ctx context.Context, v ...any)

Debug outputs debug level log message.

func Debugf

func Debugf(ctx context.Context, format string, v ...any)

Debugf outputs debug level log message.

func Error

func Error(ctx context.Context, v ...any)

Error outputs error level log message.

func Errorf

func Errorf(ctx context.Context, format string, v ...any)

Errorf outputs warn level log message.

func Info

func Info(ctx context.Context, v ...any)

Info outputs info level log message.

func Infof

func Infof(ctx context.Context, format string, v ...any)

Infof outputs info level log message.

func SetLogger

func SetLogger(logger Logger)

SetLogger updates the global logger.

func Warn

func Warn(ctx context.Context, v ...any)

Warn outputs warn level log message.

func Warnf

func Warnf(ctx context.Context, format string, v ...any)

Warnf outputs warn level log message.

func WithLogger

func WithLogger(ctx context.Context, logger Logger) context.Context

WithLogger set the context logger.

Types

type LogLevel

type LogLevel int

LogLevel represents the severity of a log message, where a higher value means more severe. The integer value should not be serialized as it is subject to change.

const (
	// LogLevelDebug is debug level.
	LogLevelDebug LogLevel = iota + 1

	// LogLevelInfo is info level.
	LogLevelInfo

	// LogLevelWarn is warn level.
	LogLevelWarn

	// LogLevelError is error level.
	LogLevelError

	// LogLevelSilent disables the log of the xray tracer.
	LogLevelSilent
)

func (LogLevel) String

func (ll LogLevel) String() string

type Logger

type Logger interface {
	// Log outputs the msg into the log. msg is fmt.Stringer because of lazy evaluation.
	// It may be called concurrently from multiple goroutines.
	Log(ctx context.Context, level LogLevel, msg fmt.Stringer)
}

Logger is the logging interface used by X-Ray YA-SDK.

func ContextLogger

func ContextLogger(ctx context.Context) Logger

ContextLogger returns the context logger. If the context has no logger, returns the global logger.

func NewDefaultLogger

func NewDefaultLogger(w io.Writer, minLevel LogLevel) Logger

NewDefaultLogger returns new logger that outputs into w.

type NullLogger added in v0.0.2

type NullLogger struct{}

NullLogger suppress all logs.

func (NullLogger) Log added in v0.0.2

Log implements Logger.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL