logging

package
v0.0.52 Latest Latest
Warning

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

Go to latest
Published: May 22, 2025 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
const (
	EventLogCreated pubsub.EventType = "log_created"
)

Variables

This section is empty.

Functions

func Create

func Create(ctx context.Context, timestamp time.Time, level, message string, attributes map[string]string, sessionID string) error

func InitService

func InitService(dbConn *sql.DB) error

func NewSlogWriter

func NewSlogWriter() io.Writer

func RecoverPanic

func RecoverPanic(name string, cleanup func())

RecoverPanic is a common function to handle panics gracefully. It logs the error, creates a panic log file with stack trace, and executes an optional cleanup function.

func Subscribe

func Subscribe(ctx context.Context) <-chan pubsub.Event[Log]

Types

type Log

type Log struct {
	ID         string
	SessionID  string
	Timestamp  time.Time
	Level      string
	Message    string
	Attributes map[string]string
	CreatedAt  time.Time
}

func ListAll

func ListAll(ctx context.Context, limit int) ([]Log, error)

func ListBySession

func ListBySession(ctx context.Context, sessionID string) ([]Log, error)

type Service

type Service interface {
	pubsub.Subscriber[Log]

	Create(ctx context.Context, timestamp time.Time, level, message string, attributes map[string]string, sessionID string) error
	ListBySession(ctx context.Context, sessionID string) ([]Log, error)
	ListAll(ctx context.Context, limit int) ([]Log, error)
}

func GetService

func GetService() Service

Jump to

Keyboard shortcuts

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