logger

package
v0.3.9 Latest Latest
Warning

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

Go to latest
Published: Dec 29, 2025 License: Apache-2.0 Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Debug

func Debug(v ...interface{})

Debug writes record into os.stdout with log level DEBUG

func Debugf

func Debugf(format string, v ...interface{})

Debugf writes record into os.stdout with log level DEBUG

func Error

func Error(v ...interface{})

Error writes record into os.stdout with log level ERROR

func Errorf

func Errorf(format string, v ...interface{})

Error writes record into os.stdout with log level ERROR

func Fatal

func Fatal(v ...interface{})

Fatal writes record into os.stdout with log level ERROR and exits

func Fatalf

func Fatalf(format string, v ...interface{})

Fatal writes record into os.stdout with log level ERROR

func FileLogger

func FileLogger(content any, fileName, fileExtension string) error

CreateFile creates a new file or overwrites an existing one with the specified filename, path, extension,

func FileLoggerWithPath added in v0.2.1

func FileLoggerWithPath(content any, path string) error

func Info

func Info(v ...interface{})

Info writes record into os.stdout with log level INFO

func Infof

func Infof(format string, v ...interface{})

Info writes record into os.stdout with log level INFO

func Init

func Init()

func LogRequest

func LogRequest(req *http.Request)

func LogResponse

func LogResponse(response *http.Response)

func SetupAndStartProcess

func SetupAndStartProcess(processName string, cmd *exec.Cmd) error

SetupAndStartProcess creates and starts a process with stdout and stderr logged via the logger. It handles the complete process lifecycle including starting the command and managing pipes.

func SetupProcessLogger

func SetupProcessLogger(processName string) (*ProcessOutputReader, *ProcessOutputReader, *os.File, *os.File, error)

SetupProcessLogger creates stdout and stderr readers for a process and returns write-ends that should be connected to the process stdout and stderr

func StatsLogger

func StatsLogger(ctx context.Context, statsFunc func() (int64, int64, int64))

func Warn

func Warn(v ...interface{})

Warn writes record into os.stdout with log level WARN

func Warnf

func Warnf(format string, v ...interface{})

Warn writes record into os.stdout with log level WARN

Types

type ProcessOutputReader

type ProcessOutputReader struct {
	Name    string // Name to identify the process in logs
	IsError bool   // Whether this reader handles error output
	// contains filtered or unexported fields
}

ProcessOutputReader is a struct that manages reading output from a process and forwarding it to the logger

func NewProcessLogger

func NewProcessLogger(name string, isError bool) (*ProcessOutputReader, *os.File, error)

NewProcessOutputReader creates a new ProcessOutputReader for a given process name is a prefix to identify the process in logs isError determines whether to log as Error (true) or Info (false) returns the reader and a write end that should be connected to the process output

func (*ProcessOutputReader) Close

func (p *ProcessOutputReader) Close()

Close closes the reader

func (*ProcessOutputReader) StartReading

func (p *ProcessOutputReader) StartReading()

StartReading starts reading from the process output in a goroutine and logging each line with the appropriate log level

Jump to

Keyboard shortcuts

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