lambdalog

package
v0.0.0-...-00d6cd8 Latest Latest
Warning

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

Go to latest
Published: Oct 8, 2019 License: MIT Imports: 7 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Severities = map[Severity]string{
	SeverityDebug:    "DEBUG",
	SeverityInfo:     "INFO",
	SeverityWarning:  "WARNING",
	SeverityError:    "ERROR",
	SeverityCritical: "CRITICAL",
}

Functions

func FileInfo

func FileInfo(depth int) (string, string, int)

func NewContextWithLogger

func NewContextWithLogger(parent context.Context, l *Logger) context.Context

Types

type Config

type Config struct {
	Type            string
	DefaultSeverity Severity
	OutputSeverity  Severity
	JsonIndent      bool
	ElapsedUnit     time.Duration
}

func NewConfigDefault

func NewConfigDefault() *Config

type LogConfig

type LogConfig struct {
	ElapsedUnit string `json:"elapsedUnit"`
}

type LogContext

type LogContext struct {
	FunctionName       string `json:"functionName"`
	FunctionVersion    string `json:"functionVersion"`
	MemoryLimitInMega  int    `json:"memoryLimitInMega"`
	InvokedFunctionArn string `json:"invokedFunctionArn"`
	AwsRequestId       string `json:"awsRequestId"`
}

func NewLogContext

func NewLogContext(ctx context.Context) *LogContext

type LogEntry

type LogEntry struct {
	Severity   Severity    `json:"severity"`
	Message    string      `json:"message"`
	Time       time.Time   `json:"time,omitempty"`
	Filename   string      `json:"filename,omitempty"`
	Fileline   int         `json:"fileline,omitempty"`
	Funcname   string      `json:"funcname,omitempty"`
	Tags       []string    `json:"tags,omitempty"`
	Elapsed    float64     `json:"elapsed,omitempty"`
	Attributes interface{} `json:"attributes,omitempty"`
	Error      string      `json:"error,omitempty"`
}

func (*LogEntry) WithAttributes

func (lr *LogEntry) WithAttributes(i interface{}) *LogEntry

func (*LogEntry) WithError

func (lr *LogEntry) WithError(err error) *LogEntry

func (*LogEntry) WithTags

func (lr *LogEntry) WithTags(tags ...string) *LogEntry

type LogRequest

type LogRequest struct {
	Type    string      `json:"type"`
	Context *LogContext `json:"context"`
	Runtime *LogRuntime `json:"runtime"`
	Config  *LogConfig  `json:"config"`
}

type LogRuntime

type LogRuntime struct {
	Severity   Severity      `json:"severity"`
	StartTime  time.Time     `json:"startTime"`
	EndTime    time.Time     `json:"endTime"`
	Elapsed    int64         `json:"elapsed"`
	Lines      []*LogEntry   `json:"lines,omitempty"`
	Tags       LogTags       `json:"tags,omitempty"`
	Severities SeverityCount `json:"-"`
}

func NewLogRuntime

func NewLogRuntime() *LogRuntime

func (*LogRuntime) AppendLogEntry

func (lr *LogRuntime) AppendLogEntry(l *LogEntry)

type LogTags

type LogTags map[string]int64

func (LogTags) CountUp

func (lt LogTags) CountUp(tags ...string)

type Logger

type Logger struct {
	Config     *Config
	LogRequest *LogRequest
}

func LoggerFromContext

func LoggerFromContext(ctx context.Context) (*Logger, bool)

func NewLogger

func NewLogger(ctx context.Context, c *Config) *Logger

func NewLoggerDefault

func NewLoggerDefault(ctx context.Context) *Logger

func (*Logger) Critical

func (l *Logger) Critical(f string, v ...interface{}) *LogEntry

func (*Logger) Debug

func (l *Logger) Debug(f string, v ...interface{}) *LogEntry

func (*Logger) Error

func (l *Logger) Error(f string, v ...interface{}) *LogEntry

func (*Logger) FillInRuntimeMetadata

func (l *Logger) FillInRuntimeMetadata()

func (*Logger) Finish

func (l *Logger) Finish()

func (*Logger) Info

func (l *Logger) Info(f string, v ...interface{}) *LogEntry

func (*Logger) Record

func (l *Logger) Record(severity Severity, message string) *LogEntry

func (*Logger) Start

func (l *Logger) Start() func()

func (*Logger) Warning

func (l *Logger) Warning(f string, v ...interface{}) *LogEntry

type Manager

type Manager struct {
	Config *Config
}

func NewManager

func NewManager(mc *Config) *Manager

func NewManagerDefault

func NewManagerDefault() *Manager

func (*Manager) Recording

func (m *Manager) Recording(ctx context.Context) (*Logger, func())

func (*Manager) RecordingInContext

func (m *Manager) RecordingInContext(ctx context.Context) (context.Context, func())

type Severity

type Severity int
const (
	SeverityUnknown Severity = iota
	SeverityDebug
	SeverityInfo
	SeverityWarning
	SeverityError
	SeverityCritical
)

func (Severity) MarshalJSON

func (s Severity) MarshalJSON() ([]byte, error)

func (Severity) String

func (s Severity) String() string

type SeverityCount

type SeverityCount map[Severity]int64

func (SeverityCount) CountUp

func (sc SeverityCount) CountUp(s Severity)

func (SeverityCount) HighestSeverity

func (sc SeverityCount) HighestSeverity() Severity

Jump to

Keyboard shortcuts

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