log

package
v4.0.5 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrorDashboard = &DashboardWriter{cmutex: &sync.Mutex{}, counts: 0, messages: make([]string, 0), messagesSize: 10}

ErrorDashboard is an instance of DashboardWriter

Instance is an instance of log

Functions

func Initialize

func Initialize(
	verboseWriter io.Writer,
	debugWriter io.Writer,
	infoWriter io.Writer,
	warningWriter io.Writer,
	errorWriter io.Writer,
	level int)

Initialize log module

func PostMessageToSlack

func PostMessageToSlack(message string, attachements []SlackMessageAttachment)

PostMessageToSlack post a message to Slack Channel

func PostShutdownMessageToSlack

func PostShutdownMessageToSlack(kill bool)

PostShutdownMessageToSlack post the shutdown message to slack channel

func PostStartedMessageToSlack

func PostStartedMessageToSlack()

PostStartedMessageToSlack post the started message to slack channel

Types

type DashboardWriter

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

DashboardWriter counts each call to Write method

func (*DashboardWriter) Counts

func (c *DashboardWriter) Counts() int64

Counts returns the count number

func (*DashboardWriter) Messages

func (c *DashboardWriter) Messages() []string

Messages returns the last logged messages

func (*DashboardWriter) Write

func (c *DashboardWriter) Write(p []byte) (n int, err error)

type SlackMessageAttachment

type SlackMessageAttachment struct {
	Fallback string                         `json:"fallback"`
	Text     string                         `json:"text,omitempty"`
	Pretext  string                         `json:"pretext,omitempty"`
	Color    string                         `json:"color"` // Can either be one of 'good', 'warning', 'danger', or any hex color code
	Fields   []SlackMessageAttachmentFields `json:"fields"`
}

SlackMessageAttachment attach message struct

type SlackMessageAttachmentFields

type SlackMessageAttachmentFields struct {
	Title string `json:"title"`
	Value string `json:"value"`
	Short bool   `json:"short"`
}

SlackMessageAttachmentFields attachment field struct

type SlackWriter

type SlackWriter struct {
	WebHookURL  string
	Channel     string
	RefreshRate int
	// contains filtered or unexported fields
}

SlackWriter writes messages to Slack user or channel. Implements io.Writer interface

func (*SlackWriter) PostNow

func (w *SlackWriter) PostNow(msg []byte, attachements []SlackMessageAttachment) (err error)

PostNow post a message directly to slack channel

func (*SlackWriter) Write

func (w *SlackWriter) Write(p []byte) (n int, err error)

Write the message to slack webhook

Jump to

Keyboard shortcuts

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