Skip to content

Latest commit

 

History

History
99 lines (72 loc) · 2.42 KB

compatibility.md

File metadata and controls

99 lines (72 loc) · 2.42 KB

Backward Compatibility

The following functions still exist, but are considered deprecated.

func Format

func Format(data map[string]interface{}) string

Format converts a map to a string of space-delimited key=val pairs

func FormatLog

func FormatLog(source string, level LogLevel, title string, data map[string]interface{}) string

FormatLog is similar to Format, but takes additional reserved params to promote logging best-practices

type LogLevel

type LogLevel string

LogLevel denotes the level of a logging

const (
	Unknown  LogLevel = "unknown"
	Critical          = "critical"
	Error             = "error"
	Warning           = "warning"
	Info              = "info"
	Trace             = "trace"
)

Constants used to define different LogLevels supported

type Logger

type Logger interface {
	Info(title string, data map[string]interface{})
	Warning(title string, data map[string]interface{})
	Error(title string, data map[string]interface{}, err error)
}

Logger is an interface satisfied by all loggers that use kayvee to Log results

Removed Compatibility

The following functions formerly existed, but have been removed.

type SentryLogger

type SentryLogger struct {
}

SentryLogger provides an wrapper methods to do logging using kayvee and optionally sending errors to kayvee.

func NewSentryLogger

func NewSentryLogger(source string, logger *log.Logger, sentryClient *raven.Client) *SentryLogger

NewSentryLogger returns a new *kayvee.Logger. source is the value assigned for all logs generated by the logger log.Logger is the underlying logger used. If nil, uses log.New(os.Stderr, "", log.Ldate|log.Ltime|log.Lshortfile) sentryClient is used to optionally route errors to sentry.

func (*SentryLogger) Error

func (l *SentryLogger) Error(title string, data map[string]interface{}, err error)

Error writes a log with level kayvee.Error If the logger was initialized with a sentryClient and error is not nil, captures the error for sentry and assigns the event ID to the sentry_event_id key in the data.

func (*SentryLogger) Info

func (l *SentryLogger) Info(title string, data map[string]interface{})

Info writes a log with level kayvee.Info

func (*SentryLogger) Warning

func (l *SentryLogger) Warning(title string, data map[string]interface{})

Warning writes a log with level kayvee.Warning