Skip to content

logger

import "github.com/Mini-Vending/go-services/packages/logger"

Index

Constants

const (
    LogContext = "log_context"
)

type LogOptions

type LogOptions struct {
    RequestID string
    Method    string
    App       string
    Protocol  Protocol
    Role      string
    AccountID int64
}

type LogOptionsFunc

type LogOptionsFunc func(l *LogOptions)

type Logger

Logger defines the interface for logging operations

type Logger interface {
    // Basic logging methods
    Debug(args ...interface{})
    Info(args ...interface{})
    Warn(args ...interface{})
    Error(args ...interface{})
    Fatal(args ...interface{})

    // Formatted logging methods
    Debugf(format string, args ...interface{})
    Infof(format string, args ...interface{})
    Warnf(format string, args ...interface{})
    Errorf(format string, args ...interface{})
    Fatalf(format string, args ...interface{})

    // Context methods
    DebugCtx(ctx context.Context, args ...interface{})
    InfoCtx(ctx context.Context, args ...interface{})
    WarnCtx(ctx context.Context, args ...interface{})
    ErrorCtx(ctx context.Context, args ...interface{})
    FatalCtx(ctx context.Context, args ...interface{})

    // Context getters
    GetLogContext(ctx context.Context) *LogOptions

    // Context setters
    SetLogContext(ctx context.Context, values ...LogOptionsFunc) context.Context
    WithRequestID(requestID string) LogOptionsFunc
    WithMethod(method string) LogOptionsFunc
    WithApp(app string) LogOptionsFunc
    WithProtocol(protocol Protocol) LogOptionsFunc
    WithAccountID(accountID int64) LogOptionsFunc
    WithRole(role string) LogOptionsFunc
}

func New

func New(level string) Logger

type Protocol

type Protocol string

const (
    ProtocolGRPC Protocol = "grpc"
    ProtocolHTTP Protocol = "http"
)

Generated by gomarkdoc