logging

package
v0.5.89-alpha Latest Latest
Warning

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

Go to latest
Published: Jul 23, 2025 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddFileOutput

func AddFileOutput(logFilePath string) error

AddFileOutput adds a file write syncer to the logger

func ChangeLevel

func ChangeLevel(newLevel zapcore.Level)

ChangeLevel dynamically changes the logging level

func GetInstance

func GetInstance() *loggerSingleton

GetInstance initializes the singleton instance if it doesn't exist

func GetLogger

func GetLogger() *zap.SugaredLogger

GetLogger returns the singleton SugaredLogger instance

func GetLogsChannel

func GetLogsChannel() <-chan LogMessage

GetLogsChannel returns the logs channel

Types

type ChannelCore

type ChannelCore struct {
	LevelEnabler zapcore.LevelEnabler
	// contains filtered or unexported fields
}

ChannelCore is a custom zapcore.Core that writes logs to a channel

func (*ChannelCore) Check

Check determines whether the supplied Entry should be logged

func (*ChannelCore) Enabled

func (c *ChannelCore) Enabled(level zapcore.Level) bool

Enabled checks if the log level is enabled

func (*ChannelCore) Sync

func (c *ChannelCore) Sync() error

Sync flushes buffered logs (no-op in this case)

func (*ChannelCore) With

func (c *ChannelCore) With(fields []zapcore.Field) zapcore.Core

With adds structured context to the Core

func (*ChannelCore) Write

func (c *ChannelCore) Write(entry zapcore.Entry, fields []zapcore.Field) error

Write writes the log entry to the rotating buffer

type DynamicWriteSyncer

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

DynamicWriteSyncer manages multiple write syncers

func (*DynamicWriteSyncer) AddWriteSyncer

func (d *DynamicWriteSyncer) AddWriteSyncer(ws zapcore.WriteSyncer)

func (*DynamicWriteSyncer) Sync

func (d *DynamicWriteSyncer) Sync() error

func (*DynamicWriteSyncer) Write

func (d *DynamicWriteSyncer) Write(p []byte) (n int, err error)

type LogMessage

type LogMessage struct {
	Level   zapcore.Level
	Message string
	Time    time.Time
}

LogMessage represents a single log entry

func GetLogs

func GetLogs() []LogMessage

GetLogs returns the last 10 logs in FIFO order

Jump to

Keyboard shortcuts

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