logger

package module
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: May 9, 2020 License: MIT Imports: 10 Imported by: 0

README

Little Logger

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Debug

func Debug(fields Fields) error

Debug calls Debug for the initialized Logger.

func Error

func Error(fields Fields) error

Error calls Error for the initialized Logger.

func Info

func Info(fields Fields) error

Info calls Info for the initialized Logger.

Types

type CloudWatchLogEventList

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

CloudWatchLogEventList stores a thread safe slice of InputLogEvents. size is the current size in bytes of the log messages.

func (*CloudWatchLogEventList) Add

func (c *CloudWatchLogEventList) Add(message string) error

Add adds a new InputLogEvent to the logEvents slice.

func (*CloudWatchLogEventList) CanAdd

func (c *CloudWatchLogEventList) CanAdd(message []byte) bool

CanAdd checks if message can be added to the logEvents slice by first checking if size will still be less than maxBatchInputLogEventSize with message being appended.

func (*CloudWatchLogEventList) IsFull

func (c *CloudWatchLogEventList) IsFull() bool

IsFull checks if size is greater than or equal to maxBatchInputLogEventSize.

type CloudWatchLogger

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

CloudWatchLogger is a structured logger that logs to CloudWatch and is thread safe.

func NewCloudWatchLogger

func NewCloudWatchLogger(sess *session.Session, logGroupName string, globalFields Fields) (*CloudWatchLogger, error)

NewCloudWatchLogger initializes a new CloudWatchLogger object and returns it. sess is an AWS session. logGroupName is the name of the log group in CloudWatch. globalFields are the fields that are written in every log message.

func (*CloudWatchLogger) Debug

func (c *CloudWatchLogger) Debug(fields Fields) error

Debug writes a log message at a debug level.

func (*CloudWatchLogger) Error

func (c *CloudWatchLogger) Error(fields Fields) error

Error writes a log message at an error level.

func (*CloudWatchLogger) Info

func (c *CloudWatchLogger) Info(fields Fields) error

Info writes a log message at an info level.

type Fields

type Fields map[string]interface{}

Fields is a map that is written in a log message.

type Logger

type Logger interface {
	Info(fields Fields) error
	Error(fields Fields) error
	Debug(fields Fields) error
}

Logger is a structured logger interface.

var Log Logger

Log is the package wide Logger. This can be used to have a Logger that is globally available within a codebase.

type StandardLogger

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

StandardLogger is a structured logger that is thread safe.

func NewStandardLogger

func NewStandardLogger(output io.Writer, globalFields Fields) *StandardLogger

NewStandardLogger initializes a new StandardLogger object and returns it. output is the output that the log messages are written to. globalFields are the fields that are written in every log message.

func (*StandardLogger) Debug

func (l *StandardLogger) Debug(fields Fields) error

Debug writes a log message at a debug level.

func (*StandardLogger) Error

func (l *StandardLogger) Error(fields Fields) error

Error writes a log message at an error level.

func (*StandardLogger) Info

func (l *StandardLogger) Info(fields Fields) error

Info writes a log message at an info level.

Jump to

Keyboard shortcuts

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