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 ¶
- type Notifier
- func (n *Notifier) Instance() string
- func (n *Notifier) Notify(level int, message string, args ...any)
- func (n *Notifier) SendNotificationEvent(notifyLevel int, event entity.NotificationEvent)
- func (n *Notifier) Sender() string
- func (n *Notifier) SetNotifyLevel(level int)
- func (n *Notifier) Stream() string
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) Notify ¶
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.