writers

package
v1.0.3 Latest Latest
Warning

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

Go to latest
Published: Mar 26, 2024 License: MIT Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CallbackAsyncWriter added in v1.0.0

type CallbackAsyncWriter struct {
	Writer
	// contains filtered or unexported fields
}

func NewCallbackAsyncWriter

func NewCallbackAsyncWriter(callback CallbackWriterCallback) *CallbackAsyncWriter

NewCallbackAsyncWriter returns a callbackAsyncWriter.

func (*CallbackAsyncWriter) Start added in v1.0.0

func (w *CallbackAsyncWriter) Start() error

func (*CallbackAsyncWriter) Stop added in v1.0.0

func (w *CallbackAsyncWriter) Stop()

func (*CallbackAsyncWriter) Write added in v1.0.0

func (w *CallbackAsyncWriter) Write(item *logs.Item)

type CallbackWriter added in v1.0.0

type CallbackWriter struct {
	Writer
	// contains filtered or unexported fields
}

func NewCallbackWriter

func NewCallbackWriter(callback CallbackWriterCallback) *CallbackWriter

NewCallbackWriter returns a callbackWriter.

func (*CallbackWriter) Write added in v1.0.0

func (w *CallbackWriter) Write(item *logs.Item)

type CallbackWriterCallback

type CallbackWriterCallback func(*logs.Item) error

CallbackWriterCallback define the writer callback.

type FileRotateWriter added in v1.0.2

type FileRotateWriter struct {
	Writer
	// contains filtered or unexported fields
}

func NewFileRotateWriter added in v1.0.2

func NewFileRotateWriter(filename string, rotateAfter time.Duration, deleteNotCritical bool) (*FileRotateWriter, error)

NewFileRotateWriter returns a FileRotateWriter. - rotateAfter: how long between one rotation and another (0 = no rotation). - deleteNotCritical: if True removes the rotations that do not contain critical logs.

func (*FileRotateWriter) Stop added in v1.0.2

func (w *FileRotateWriter) Stop()

func (*FileRotateWriter) Write added in v1.0.2

func (w *FileRotateWriter) Write(item *logs.Item)

type FileWriter added in v1.0.0

type FileWriter struct {
	Writer
	// contains filtered or unexported fields
}

func NewFileWriter

func NewFileWriter(filename string) (*FileWriter, error)

NewFileWriter returns a fileWriter.

func (*FileWriter) Stop added in v1.0.0

func (w *FileWriter) Stop()

func (*FileWriter) Write added in v1.0.0

func (w *FileWriter) Write(item *logs.Item)

type OnItemFunc added in v1.0.0

type OnItemFunc func(*logs.Item) error

type StateChangeCallback

type StateChangeCallback func(bool)

StateChangeCallback is called (true) when first client connecting, and (false) when there are no more clients.

type StdoutWriter added in v1.0.0

type StdoutWriter struct {
	Writer
	// contains filtered or unexported fields
}

func NewStdoutWriter

func NewStdoutWriter() *StdoutWriter

NewStdoutWriter returns a stdoutWriter.

func (*StdoutWriter) Write added in v1.0.0

func (w *StdoutWriter) Write(item *logs.Item)

type SyslogWriter added in v1.0.0

type SyslogWriter struct {
	Writer
	// contains filtered or unexported fields
}

func NewSyslogWriter

func NewSyslogWriter(tag string) *SyslogWriter

If tag is empty, the os.Args[0] is used.

func (*SyslogWriter) Stop added in v1.0.0

func (w *SyslogWriter) Stop()

func (*SyslogWriter) Write added in v1.0.0

func (w *SyslogWriter) Write(item *logs.Item)

type TcpWriter added in v1.0.0

type TcpWriter struct {
	Writer
	// contains filtered or unexported fields
}

func NewTCPWriter

func NewTCPWriter(address string, port int, debug bool, cb StateChangeCallback) (*TcpWriter, error)

Ritorna un nuovo TCP Writer. - debug: se attivo logga in feedback eventuali errori e cambi di stato.

func (*TcpWriter) Start added in v1.0.0

func (w *TcpWriter) Start() error

func (*TcpWriter) Stop added in v1.0.0

func (w *TcpWriter) Stop()

func (*TcpWriter) Write added in v1.0.0

func (w *TcpWriter) Write(item *logs.Item)

type TelegramWriter added in v1.0.0

type TelegramWriter struct {
	Writer
	// contains filtered or unexported fields
}

func NewTelegramWriter

func NewTelegramWriter(botAPIKey string, channelID int) *TelegramWriter

NewTelegramWriter returns a telegramWriter.

func (*TelegramWriter) Start added in v1.0.0

func (w *TelegramWriter) Start() error

func (*TelegramWriter) Stop added in v1.0.0

func (w *TelegramWriter) Stop()

func (*TelegramWriter) Write added in v1.0.0

func (w *TelegramWriter) Write(item *logs.Item)

Write enqueue an item and returns immediately, or blocks while the internal queue is full.

type Writer added in v1.0.0

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

Implementa i metodi base.

func (*Writer) Enqueue added in v1.0.0

func (w *Writer) Enqueue(item *logs.Item)

Ritorna immediatamente.

func (*Writer) Feedback added in v1.0.0

func (w *Writer) Feedback(level logs.Level, args ...any)

Genera un item e lo invia al writer di default del rispettivo livello.

func (*Writer) FeedbackError added in v1.0.0

func (w *Writer) FeedbackError(err error)

Incapsula e invia un errore al writer di default del livello ErrorLevel.

func (*Writer) Feedbackf added in v1.0.0

func (w *Writer) Feedbackf(level logs.Level, format string, args ...any)

Genera un item e lo invia al writer di default del rispettivo livello.

func (*Writer) ID added in v1.0.0

func (w *Writer) ID() string

func (*Writer) SetFeedbackChan added in v1.0.0

func (w *Writer) SetFeedbackChan(ch chan *logs.Item)

Imposta il canale interno di feeback. Viene invocata dal logger quando imposta un nuovo writer per un certo livello.

func (*Writer) Start added in v1.0.0

func (w *Writer) Start() error

func (*Writer) StartQueue added in v1.0.0

func (w *Writer) StartQueue(queueSize int, f OnItemFunc)

Avvia il worker di gestione della coda, invocando la callback OnItemFunc() per ogni item da processare. Se la callback ritorna errore questo viene feedbackato al writer di default del rispettivo livello.

func (*Writer) Stop added in v1.0.0

func (w *Writer) Stop()

func (*Writer) StopQueue added in v1.0.0

func (w *Writer) StopQueue(timeoutSecs int)

Finisce di consegnare gli item rimanenti in coda e termina.

Jump to

Keyboard shortcuts

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