loggers

package
v1.6.0 Latest Latest
Warning

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

Go to latest
Published: Jan 2, 2024 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func MakeThreadSafeLogger

func MakeThreadSafeLogger(level log.Level, logFile string) (*log.Logger, error)

MakeThreadSafeLogger returns a logger that is synchronized with the internal mutex, if no file is provided write to os.Stdout.

func MakeThreadSafeLoggerWithWriter

func MakeThreadSafeLoggerWithWriter(level log.Level, writer io.Writer) *log.Logger

MakeThreadSafeLoggerWithWriter creates a logger using a ThreadSafeWriter output.

Types

type ThreadSafeWriter

type ThreadSafeWriter struct {
	Writer io.Writer
	Mutex  *sync.Mutex
}

ThreadSafeWriter a struct that implements io.Writer in a threadsafe way

func (ThreadSafeWriter) Write

func (w ThreadSafeWriter) Write(p []byte) (n int, err error)

Write writes p bytes with the mutex

Jump to

Keyboard shortcuts

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