notifications

package
v1.3.0 Latest Latest
Warning

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

Go to latest
Published: Apr 24, 2021 License: Apache-2.0 Imports: 23 Imported by: 0

Documentation

Overview

Package notifications ... Copyright 2010 The Go Authors. All rights reserved. Use of this source code is governed by a BSD-style license.

Index

Constants

View Source
const ColorHex = "#406170"

ColorHex is the default notification color used for services that support it (formatted as a CSS hex string)

View Source
const ColorInt = 0x406170

ColorInt is the default notification color used for services that support it (as an int value)

Variables

This section is empty.

Functions

func GetTitle added in v1.2.0

func GetTitle() (title string)

GetTitle returns a common notification title with hostname appended

func NewEmailNotifier added in v1.1.6

func NewEmailNotifier(c *cobra.Command, acceptedLogLevels []log.Level) t.ConvertibleNotifier

NewEmailNotifier is a factory method creating a new email notifier instance

func NewGotifyNotifier added in v1.1.6

func NewGotifyNotifier(c *cobra.Command, levels []log.Level) t.ConvertibleNotifier

NewGotifyNotifier is a factory method creating a new gotify notifier instance

func NewMsTeamsNotifier added in v1.1.6

func NewMsTeamsNotifier(cmd *cobra.Command, acceptedLogLevels []log.Level) t.ConvertibleNotifier

NewMsTeamsNotifier is a factory method creating a new teams notifier instance

func NewSlackNotifier added in v1.1.6

func NewSlackNotifier(c *cobra.Command, acceptedLogLevels []log.Level) t.ConvertibleNotifier

NewSlackNotifier is a factory function used to generate new instance of the slack notifier type

func SendMail

func SendMail(addr string, insecureSkipVerify bool, a smtp.Auth, from string, to []string, msg []byte) error

SendMail connects to the server at addr, switches to TLS if possible, authenticates with the optional mechanism a if possible, and then sends an email from address from, to addresses to, with message msg. The addr must include a port, as in "mail.example.com:smtp".

The addresses in the to parameter are the SMTP RCPT addresses.

The msg parameter should be an RFC 822-style email with headers first, a blank line, and then the message body. The lines of msg should be CRLF terminated. The msg headers should usually include fields such as "From", "To", "Subject", and "Cc". Sending "Bcc" messages is accomplished by including an email address in the to parameter but not including it in the msg headers.

The SendMail function and the net/smtp package are low-level mechanisms and provide no support for DKIM signing, MIME attachments (see the mime/multipart package), or other mail functionality. Higher-level packages exist outside of the standard library.

func SplitSubN

func SplitSubN(s string, n int) []string

SplitSubN splits a string into a list of string with each having a maximum number of characters n

Types

type Notifier

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

Notifier can send log output as notification to admins, with optional batching.

func NewNotifier

func NewNotifier(c *cobra.Command) *Notifier

NewNotifier creates and returns a new Notifier, using global configuration.

func (*Notifier) Close added in v1.0.3

func (n *Notifier) Close()

Close closes all notifiers.

func (*Notifier) SendNotification

func (n *Notifier) SendNotification()

SendNotification sends any notifications accumulated since StartNotification() was called.

func (*Notifier) StartNotification

func (n *Notifier) StartNotification()

StartNotification starts a log batch. Notifications will be accumulated after this point and only sent when SendNotification() is called.

func (*Notifier) String added in v1.2.0

func (n *Notifier) String() string

Jump to

Keyboard shortcuts

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