log

package
v0.0.0-...-3a1fdf7 Latest Latest
Warning

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

Go to latest
Published: Dec 7, 2022 License: Apache-2.0, Apache-2.0 Imports: 11 Imported by: 0

Documentation

Overview

Package log provides the common logging facilities used by the Stellar Development foundation.

You may notice that this package does not expose the "Fatal" family of logging functions: this is intentional. This package is specifically geared to logging within the context of an http server, and our chosen path for responding to "Oh my god something is horribly wrong" within the context of an HTTP request is to panic on that request.

Index

Constants

View Source
const (
	PanicLevel = logrus.PanicLevel
	ErrorLevel = logrus.ErrorLevel
	WarnLevel  = logrus.WarnLevel
	InfoLevel  = logrus.InfoLevel
	DebugLevel = logrus.DebugLevel
)

Variables

This section is empty.

Functions

func Debug

func Debug(args ...interface{})

Debug logs a message at the debug severity.

func Debugf

func Debugf(format string, args ...interface{})

Debugf logs a message at the debug severity.

func Error

func Error(args ...interface{})

Error logs a message at the Error severity.

func Errorf

func Errorf(format string, args ...interface{})

Errorf logs a message at the Error severity.

func Fatal

func Fatal(args ...interface{})

Fatal logs a message at the Fatal severity.

func Fatalf

func Fatalf(format string, args ...interface{})

Fatalf logs a message at the Fatal severity.

func Info

func Info(args ...interface{})

Info logs a message at the Info severity.

func Infof

func Infof(format string, args ...interface{})

Infof logs a message at the Info severity.

func Panic

func Panic(args ...interface{})

Panic logs a message at the Panic severity.

func Panicf

func Panicf(format string, args ...interface{})

Panicf logs a message at the Panic severity.

func PushContext

func PushContext(parent context.Context, modFn func(*Entry) *Entry) context.Context

PushContext is a helper method to derive a new context with a modified logger bound to it, where the logger is derived from the current value on the context.

func Set

func Set(parent context.Context, logger *Entry) context.Context

Set establishes a new context to which the provided sub-logger is bound

func SetLevel

func SetLevel(level logrus.Level)

func Warn

func Warn(args ...interface{})

Warn logs a message at the Warn severity.

func Warnf

func Warnf(format string, args ...interface{})

Warnf logs a message at the Warn severity.

Types

type Entry

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

Entry repre

var DefaultLogger *Entry

DefaultLogger represents the default logger that is not bound to any specific context.

func Ctx

func Ctx(ctx context.Context) *Entry

Ctx returns the logger bound to the provided context, otherwise providing the default logger.

func New

func New() *Entry

New creates a new logger, starting at a WARN level and including the current processes pid as a field.

func WithField

func WithField(key string, value interface{}) *Entry

func WithFields

func WithFields(fields F) *Entry

func WithStack

func WithStack(stackProvider interface{}) *Entry

func (*Entry) AddHook

func (e *Entry) AddHook(hook logrus.Hook)

AddHook adds a hook to the logger hooks.

func (*Entry) Ctx

func (e *Entry) Ctx(ctx context.Context) *Entry

Ctx appends all fields from `e` to the new logger created from `ctx` logger and returns it.

func (*Entry) Debug

func (e *Entry) Debug(args ...interface{})

Debug logs a message at the debug severity.

func (*Entry) Debugf

func (e *Entry) Debugf(format string, args ...interface{})

Debugf logs a message at the debug severity.

func (*Entry) DisableColors

func (e *Entry) DisableColors()

func (*Entry) DisableTimestamp

func (e *Entry) DisableTimestamp()

func (*Entry) Error

func (e *Entry) Error(args ...interface{})

Error logs a message at the Error severity.

func (*Entry) Errorf

func (e *Entry) Errorf(format string, args ...interface{})

Errorf logs a message at the Error severity.

func (*Entry) Fatal

func (e *Entry) Fatal(args ...interface{})

Fatal logs a message at the Fatal severity.

func (*Entry) Fatalf

func (e *Entry) Fatalf(format string, args ...interface{})

Fatalf logs a message at the Fatal severity.

func (*Entry) Info

func (e *Entry) Info(args ...interface{})

Info logs a message at the Info severity.

func (*Entry) Infof

func (e *Entry) Infof(format string, args ...interface{})

Infof logs a message at the Info severity.

func (*Entry) Panic

func (e *Entry) Panic(args ...interface{})

Panic logs a message at the Panic severity.

func (*Entry) Panicf

func (e *Entry) Panicf(format string, args ...interface{})

Panicf logs a message at the Panic severity.

func (*Entry) Print

func (e *Entry) Print(args ...interface{})

func (*Entry) SetLevel

func (e *Entry) SetLevel(level logrus.Level)

func (*Entry) SetOutput

func (e *Entry) SetOutput(output io.Writer)

SetOutput sets the logger output.

func (*Entry) StartTest

func (e *Entry) StartTest(level logrus.Level) func() []logrus.Entry

StartTest shifts this logger into "test" mode, ensuring that log lines will be recorded (rather than outputted). The returned function concludes the test, switches the logger back into normal mode and returns a slice of all raw logrus entries that were created during the test.

func (*Entry) Warn

func (e *Entry) Warn(args ...interface{})

Warn logs a message at the Warn severity.

func (*Entry) Warnf

func (e *Entry) Warnf(format string, args ...interface{})

Warnf logs a message at the Warn severity.

func (*Entry) WithContext

func (e *Entry) WithContext(ctx context.Context) *Entry

Add a context to the log entry.

func (*Entry) WithError

func (e *Entry) WithError(err error) *Entry

Add an error as single field to the log entry. All it does is call `WithError` for the given `error`.

func (*Entry) WithField

func (e *Entry) WithField(key string, value interface{}) *Entry

WithField creates a child logger annotated with the provided key value pair. A subsequent call to one of the logging methods (Debug(), Error(), etc.) to the return value from this function will cause the emitted log line to include the provided value.

func (*Entry) WithFields

func (e *Entry) WithFields(fields F) *Entry

WithFields creates a child logger annotated with the provided key value pairs.

func (*Entry) WithStack

func (e *Entry) WithStack(stackProvider interface{}) *Entry

WithStack annotates this error with a stack trace from `stackProvider`, if available. normally `stackProvider` would be an error that implements `errors.StackTracer`.

type F

type F logrus.Fields

F wraps the logrus.Fields type for the convenience of typing less.

type LogglyHook

type LogglyHook struct {
	FilteredKeys map[string]bool
	// contains filtered or unexported fields
}

LogglyHook sends logs to loggly

func NewLogglyHook

func NewLogglyHook(token, tag string) *LogglyHook

NewLogglyHook creates a new hook

func (*LogglyHook) Fire

func (hook *LogglyHook) Fire(entry *logrus.Entry) error

func (*LogglyHook) Flush

func (hook *LogglyHook) Flush()

func (*LogglyHook) Levels

func (hook *LogglyHook) Levels() []logrus.Level

Jump to

Keyboard shortcuts

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