golog2tgm

package module
v0.2.2 Latest Latest
Warning

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

Go to latest
Published: Jan 19, 2024 License: MIT Imports: 14 Imported by: 0

README

golog2tgm

The module is intended to act as a logger sink to gather message samples and periodically send them via Telegram

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Worker

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

func Start

func Start(
	ctx context.Context,
	srcRoot string,
	intro func(int8, int) string,
	errorHandler func(string),
) *Worker

Start worker.

srcRoot is a common part of the sources path being printed in a call stack (to exclude external calls and to truncate long paths).

intro arg is a callback to print an intro with prefered design.

errorHandler allows to log golog2tgm internal errors with a logger being used by a caller.

func (*Worker) PushMessage

func (w *Worker) PushMessage(level int8, hash uint64, msg string, pcs []uintptr)

Push message to the engine.

hash allows to identify a sample externally, e.g. via program counter. Pass 0 to match samples by golog2tgm.

pcs allows to add call stack to the sample.

func (*Worker) SetCaption

func (w *Worker) SetCaption(caption string)

Set teleram message caption (e.g. your daemon name)

func (*Worker) SetPeriod

func (w *Worker) SetPeriod(periodSec uint)

Set alerting interval in seconds

func (*Worker) SetTargetChat

func (w *Worker) SetTargetChat(apiToken string, id int64)

func (*Worker) SetTimeZone

func (w *Worker) SetTimeZone(name string, offsetSec int)

Set convenient time zone and its UTC offset in seconds

func (*Worker) Stop

func (w *Worker) Stop()

Synchronously send messages that have not yet been sent and stop the worker.

func (*Worker) Uncork added in v0.2.0

func (w *Worker) Uncork()

Force send aggregated alerts

Jump to

Keyboard shortcuts

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