io

package
v2.0.1 Latest Latest
Warning

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

Go to latest
Published: Mar 24, 2021 License: MPL-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

View Source
const (
	SeverityError   = "ERROR"
	SeverityInfo    = "INFO"
	SeverityWarning = "WARNING"
)

Variables

This section is empty.

Functions

func CloseResourceSecure

func CloseResourceSecure(name string, c io.Closer)

CloseResourceSecure allows to call closer and handle errors as warnings in logs

func CutMessageIfNeeded

func CutMessageIfNeeded(message string) string

func GenerateMessage

func GenerateMessage(eventType, message, topic string) string

func OutputError

func OutputError(err error, topic, msg string, args ...interface{})

OutputError shows error as [ERROR] {error_message}, {message} [{topic}] e.g. [ERROR] Cannot write file "tt.txt", please check permissions 664 on folder /tmp/tt.txt [order_123] topic is needed to group logged event for certain process e.g. all events which happened to order_123 we also cut line separators because normally such messages are split by them as separate messages we also cut too long messages (more than maxMessageLength chars) because of the processing overhead for long outputs

func OutputInfo

func OutputInfo(topic, msg string, args ...interface{})

OutputWarning shows warning as [INFO] {message} [{topic}] e.g. [INFO] Cannot send email [order_123]

func OutputMessageType

func OutputMessageType(messageType, topic, msg string, args ...interface{})

OutputMessageType shows a message as [{messageType}] {message} [{topic}]

func OutputSingleLine

func OutputSingleLine(message string, args ...interface{})

OutputSingleLine is deprecated should be used in internal outputs

func OutputSingleLineWithTopic

func OutputSingleLineWithTopic(topic, message string, args ...interface{})

OutputSingleLineWithTopic is deprecated should be used in internal outputs

func OutputWarning

func OutputWarning(topic, msg string, args ...interface{})

OutputWarning shows warning as [WARNING] {message} [{topic}] e.g. [WARNING] Cannot send email [order_123]

func RemoveLineBreaks

func RemoveLineBreaks(input string) string

func SetLogger

func SetLogger(l Logger)

func SetMaxMessageLength

func SetMaxMessageLength(newValue int)

Types

type DefaultLogger

type DefaultLogger struct{}

func (DefaultLogger) OutputMessageType

func (dl DefaultLogger) OutputMessageType(messageType, topic, msg string, args ...interface{})

type Logger

type Logger interface {
	OutputMessageType(messageType, topic, msg string, args ...interface{})
}

Jump to

Keyboard shortcuts

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