logger

package
v1.1.5 Latest Latest
Warning

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

Go to latest
Published: Mar 19, 2026 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Overview

Package logger provides a unified logging interface for the SDK. It supports multiple log levels and allows users to inject custom loggers.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Debug

func Debug(format string, args ...interface{})

Debug logs a debug message using the default logger.

func Error

func Error(format string, args ...interface{})

Error logs an error message using the default logger.

func Info

func Info(format string, args ...interface{})

Info logs an informational message using the default logger.

func SetDefault

func SetDefault(logger Logger)

SetDefault sets the default logger for the SDK.

func SetLevel

func SetLevel(level Level)

SetLevel sets the log level for the default logger.

func Warn

func Warn(format string, args ...interface{})

Warn logs a warning message using the default logger.

Types

type Level

type Level int

Level represents the severity level of a log message.

const (
	// LevelDebug is for detailed debugging information.
	LevelDebug Level = iota
	// LevelInfo is for general informational messages.
	LevelInfo
	// LevelWarn is for warning messages.
	LevelWarn
	// LevelError is for error messages.
	LevelError
	// LevelNone disables all logging.
	LevelNone
)

func GetLevel

func GetLevel() Level

GetLevel returns the current log level of the default logger.

func (Level) String

func (l Level) String() string

String returns the string representation of the log level.

type Logger

type Logger interface {
	Debug(format string, args ...interface{})
	Info(format string, args ...interface{})
	Warn(format string, args ...interface{})
	Error(format string, args ...interface{})
	SetLevel(level Level)
	GetLevel() Level
}

Logger is the interface for logging in the SDK.

func GetDefault

func GetDefault() Logger

GetDefault returns the default logger.

type NoOpLogger

type NoOpLogger struct{}

NoOpLogger is a logger that does nothing.

func NewNoOpLogger

func NewNoOpLogger() *NoOpLogger

NewNoOpLogger creates a new no-op logger.

func (*NoOpLogger) Debug

func (l *NoOpLogger) Debug(format string, args ...interface{})

Debug does nothing.

func (*NoOpLogger) Error

func (l *NoOpLogger) Error(format string, args ...interface{})

Error does nothing.

func (*NoOpLogger) GetLevel

func (l *NoOpLogger) GetLevel() Level

GetLevel returns LevelNone.

func (*NoOpLogger) Info

func (l *NoOpLogger) Info(format string, args ...interface{})

Info does nothing.

func (*NoOpLogger) SetLevel

func (l *NoOpLogger) SetLevel(level Level)

SetLevel does nothing.

func (*NoOpLogger) Warn

func (l *NoOpLogger) Warn(format string, args ...interface{})

Warn does nothing.

type StandardLogger

type StandardLogger struct {
	// contains filtered or unexported fields
}

StandardLogger is the default logger implementation using Go's standard log package.

func NewStandardLogger

func NewStandardLogger(level Level, out io.Writer) *StandardLogger

NewStandardLogger creates a new standard logger with the specified level and output.

func (*StandardLogger) Debug

func (l *StandardLogger) Debug(format string, args ...interface{})

Debug logs a debug message.

func (*StandardLogger) Error

func (l *StandardLogger) Error(format string, args ...interface{})

Error logs an error message.

func (*StandardLogger) GetLevel

func (l *StandardLogger) GetLevel() Level

GetLevel returns the current log level.

func (*StandardLogger) Info

func (l *StandardLogger) Info(format string, args ...interface{})

Info logs an informational message.

func (*StandardLogger) SetLevel

func (l *StandardLogger) SetLevel(level Level)

SetLevel sets the minimum log level.

func (*StandardLogger) Warn

func (l *StandardLogger) Warn(format string, args ...interface{})

Warn logs a warning message.

Jump to

Keyboard shortcuts

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