eventlogger

package
v0.7.0 Latest Latest
Warning

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

Go to latest
Published: Feb 11, 2020 License: MIT Imports: 10 Imported by: 9

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewEventLoggerContext

func NewEventLoggerContext(ctx context.Context, logger *Logger) context.Context

NewEventLoggerContext returns a context with the Logger embedded as a value

func StandardLogger

func StandardLogger(l *Logger) *log.Logger

StandardLogger returns a log.Logger that writes to l, or a default logger to stdout if l is nil

Types

type EventLoggerContextKey

type EventLoggerContextKey string

type Logger

type Logger struct {
	DL   persistence.EventLoggerDataLayer
	ID   uuid.UUID
	Sink io.Writer
	// ExcludeID determines whether to omit the ID from log strings
	ExcludeID bool
}

Logger is an object that writes log lines to the database in an EventLog as well as to Sink

func GetLogger

func GetLogger(ctx context.Context) *Logger

GetLogger returns the Logger if present or a default logger that logs to stdout if not present

func (*Logger) Init

func (l *Logger) Init(webhook []byte, repo string, pr uint) error

Init initializes the EventLog object in the database. This must be called exactly once prior to any log lines.

func (*Logger) Printf

func (l *Logger) Printf(msg string, params ...interface{})

Printf writes the formatted log line to

func (*Logger) SetEnvName

func (l *Logger) SetEnvName(name string) error

SetEnvName sets the environment name for this logger. Init must be called first.

Jump to

Keyboard shortcuts

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