log

package module
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Dec 30, 2019 License: Apache-2.0 Imports: 13 Imported by: 26

README

log

Build Status Go Report Card GoDoc License PRs Welcome

log

Documentation

Index

Constants

View Source
const (
	// InfoSeverity is the severity for non-serious information
	InfoSeverity = iota

	// WarnSeverity is for concerning information that does not stop the flow of the application but is concerning
	WarnSeverity

	// ErrorSeverity is for events that prevent normal flow of the application
	ErrorSeverity

	// CritSeverity is for series issues that occur in the application
	CritSeverity

	// FatalSeverity is for serious events that occur during execution
	FatalSeverity

	// InfoDetail is used in logs to discern that it is informational
	InfoDetail = "INFO"

	// WarnDetail is used in logs to discern that it is a warning
	WarnDetail = "WARN"

	// ErrorDetail is used in logs to discern that it is an error
	ErrorDetail = "ERROR"

	// CriticalDetail is used in logs to discern that it is a critical error
	CriticalDetail = "CRITICAL"

	// FatalDetail is used in logs to discern that it is a fatal error
	FatalDetail = "FATAL"

	// InfoColor defines the color for info logs
	InfoColor = "\033[0;32m"

	// WarnColor defines the color for warning logs
	WarnColor = "\033[1;33m"

	// ErrorColor defines the color for error logs
	ErrorColor = "\033[0;31m"

	// CriticalColor defines the color for critical logs
	CriticalColor = "\033[1;31m"

	// FatalColor defines the color for fatal logs
	FatalColor = "\033[0;35m"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Log

type Log struct {
	Type          int       `json:"type"`
	Text          string    `json:"text"`
	TimeStamp     time.Time `json:"timestamp"`
	Error         error     `json:"error"`
	StackTrace    string    `json:"stackTrace"`
	SpecialAppend string    `json:"special"`

	JobID        string `json:"jobId"`
	Job          string `json:"job"`
	OrgCode      string `json:"org_code"`
	JobInSource  string `json:"inSource"`
	JobOutSource string `json:"outSource"`

	IsDebug bool `json:"isDebug"`
	Slack   bool `json:"slack"`
}

Log is a struct that holds all the information required to log an event

func Critical

func Critical(text string, err error) (log Log)

Critical creates a log for series issues that occur in the application

func Criticalf

func Criticalf(err error, format string, a ...interface{}) (log Log)

Criticalf creates a log for series issues that occur in the application allowing a formatting string to be passed for the log rather than a straight string parameter

func Debug

func Debug(text string) (log Log)

Debug creates a log for helpful information that might not be needed

func Debugf

func Debugf(format string, a ...interface{}) (log Log)

Debugf creates a log for helpful information that might not be needed allowing a formatting string to be passed for the log rather than a straight string parameter

func Error

func Error(text string, err error) (log Log)

Error creates a log for events that prevent normal flow of the application

func Errorf

func Errorf(err error, format string, a ...interface{}) (log Log)

Errorf creates a log for events that prevent normal flow of the application allowing a formatting string to be passed for the log rather than a straight string parameter

func Fatal

func Fatal(text string, err error) (log Log)

Fatal creates a log for serious events that occur during execution

func Fatalf

func Fatalf(err error, format string, a ...interface{}) (log Log)

Fatalf creates a log for serious events that occur during execution allowing a formatting string to be passed for the log rather than a straight string parameter noinspection GoUnusedExportedFunction

func Info

func Info(text string) (log Log)

Info creates a log for non-serious information

func Infof

func Infof(format string, a ...interface{}) (log Log)

Infof creates a log for non-serious information allowing a formatting string to be passed for the log rather than a straight string parameter

func Warning

func Warning(text string, err error) (log Log)

Warning creates a log for concerning information that does not stop the flow of the application but is concerning

func Warningf

func Warningf(err error, format string, a ...interface{}) (log Log)

Warningf creates a log for concerning information that does not stop the flow of the application but is concerning allowing a formatting string to be passed for the log rather than a straight string parameter

func (Log) Debug

func (log Log) Debug() Log

Debug turns on the debug flag in the log and returns the log so that the methods may be chained

func (Log) Special

func (log Log) Special(special string) Log

Special sets the SpecialAppend field which is used when extra information needs to be included in the log

func (Log) Stack

func (log Log) Stack(stacktrace string) Log

Stack sets the stacktrace for the log

func (Log) ToConsoleString

func (log Log) ToConsoleString() (logString string)

ToConsoleString returns the string formatted for the console

func (Log) ToString

func (log Log) ToString() (logString string)

ToString returns a string-formatted version of the log

func (Log) TypeToColorCode

func (log Log) TypeToColorCode(Type int) (color string)

TypeToColorCode returns the characters that change the terminal output color according to the log type

func (Log) TypeToString

func (log Log) TypeToString(Type int) (TypeString string)

TypeToString returns a readable version of the log type

type Logger

type Logger interface {
	Send(log Log)
}

Logger is the interface that defines the required method for processing a log

func NewLogStream

func NewLogStream(ctx context.Context, dbconn connection.DatabaseConnection, logconfig config) (Logger, error)

NewLogStream creates and returns a logger

type SNSClient

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

SNSClient can be used for pushing messages to a topic which are then emailed to all users who are subscribed to that topic

func NewSNSClient

func NewSNSClient(ctx context.Context, topicID string) (client *SNSClient, err error)

NewSNSClient creates a client for creating emails VIA Amazon SNS using the [default] credentials stored in ~/.aws/credentials

func (*SNSClient) PushMessage

func (client *SNSClient) PushMessage(message string)

PushMessage pushes the message to sns

type Stream

type Stream = chan<- Log

Stream is a type alias for the log logStream to make it less awkward

Jump to

Keyboard shortcuts

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