log

package
v5.10.2 Latest Latest
Warning

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

Go to latest
Published: May 29, 2025 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type HistoricLogger

type HistoricLogger interface {
	logging.LoggerInterface
	Messages(level int) []string
	TotalCount(level int) int64
}

HistoricLogger defines the interface for a logger that allows keeping the last N messages buffered and querying them

type HistoricLoggerWrapper

type HistoricLoggerWrapper struct {
	logging.LoggerInterface
	// contains filtered or unexported fields
}

HistoricLoggerWrapper is an implementation of the HistoricLogger interface

func BuildFromConfig

func BuildFromConfig(cfg *conf.Logging, prefix string, slackCfg *conf.Slack) *HistoricLoggerWrapper

BuildFromConfig creates a logger from a config

func NewHistoricLoggerWrapper

func NewHistoricLoggerWrapper(l logging.LoggerInterface, enabled [logLevelCount]bool, size int) *HistoricLoggerWrapper

NewHistoricLoggerWrapper constructs a new historic logger

func (*HistoricLoggerWrapper) Debug

func (l *HistoricLoggerWrapper) Debug(msg ...interface{})

Debug writes a log message with debug level

func (*HistoricLoggerWrapper) Error

func (l *HistoricLoggerWrapper) Error(msg ...interface{})

Error writes a log message with Error level

func (*HistoricLoggerWrapper) Info

func (l *HistoricLoggerWrapper) Info(msg ...interface{})

Info writes a log message with info level

func (*HistoricLoggerWrapper) Messages

func (l *HistoricLoggerWrapper) Messages(level int) []string

Messages returns the buffered messages for a specific level

func (*HistoricLoggerWrapper) TotalCount

func (l *HistoricLoggerWrapper) TotalCount(level int) int64

TotalCount returns the total number of messages logged for a specific level

func (*HistoricLoggerWrapper) Verbose

func (l *HistoricLoggerWrapper) Verbose(msg ...interface{})

Verbose writes a log message with verbose level

func (*HistoricLoggerWrapper) Warning

func (l *HistoricLoggerWrapper) Warning(msg ...interface{})

Warning writes a log message with Warning level

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 {
	// contains filtered or unexported fields
}

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

func NewSlackWriter

func NewSlackWriter(webhookURL string, channel string) *SlackWriter

NewSlackWriter constructs a slack writer

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