notify

package
v0.6.2 Latest Latest
Warning

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

Go to latest
Published: May 4, 2023 License: MIT Imports: 7 Imported by: 1

Documentation

Overview

Package notify is used internally by Geist to send/log operational events. It is made externally accessible mainly for Geist connector development, since the connector internals also should send important events to the this channel. The common notify channel is passed to the connector in its New() constructor func.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Notifier

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

Notifier provides a way to send notification/log events to both an externally accessible channel and to log framework.

func New

func New(ch entity.NotifyChan, log *logger.Log, callerLevel int, sender, instance, stream string) *Notifier

New creates a new Notifier. For proper value on the caller func name, set `callerLevel` to:

1 - if the notifying func is immediately above the called Notify()
2 - if the notifying func is two levels above
... etc

The minimum log level to use is set to OS env variable "LOG_LEVEL". If not found or invalid it is set to "INFO". Min level can be re-set with SetNotifyLevel().

func (*Notifier) Instance

func (n *Notifier) Instance() string

func (*Notifier) Notify

func (n *Notifier) Notify(level int, message string, args ...any)

Notify sends the provided data to the provided channel (and optionally log framework), together with additional data depending on notification level:

DEBUG and INFO: name of calling func
WARN: as INFO plus file and line number
ERROR: as WARN plus the full stack trace.

func (*Notifier) SendNotificationEvent

func (n *Notifier) SendNotificationEvent(notifyLevel int, event entity.NotificationEvent)

SendNotificationEvent takes a formatted NotificationEvent, enrich it with info such as func, file, line, call stack, and sends it to the channel.

func (*Notifier) Sender

func (n *Notifier) Sender() string

func (*Notifier) SetNotifyLevel

func (n *Notifier) SetNotifyLevel(level int)

func (*Notifier) Stream

func (n *Notifier) Stream() string

Jump to

Keyboard shortcuts

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