logmgr

package module
v1.1.1 Latest Latest
Warning

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

Go to latest
Published: Nov 15, 2021 License: GPL-3.0 Imports: 9 Imported by: 0

README

logmgr

logmgr is a simple library to combine logrus and Sentry for Go applications making use of the Gin HTTP framework.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Logger

type Logger struct {
	*logrus.Entry
	// contains filtered or unexported fields
}

Logger extends a logrus logger by providing path-like names.

func NewPlainLogger added in v1.0.2

func NewPlainLogger(name string, level logrus.Level) *Logger

NewPlainLogger creates a Logger without a SentryManager.

func (*Logger) Extend

func (l *Logger) Extend(name string) *Logger

Extend returns a Logger with an extended name path.

func (*Logger) Recovery added in v1.1.0

func (l *Logger) Recovery() gin.HandlerFunc

func (*Logger) WithGin

func (l *Logger) WithGin(c *gin.Context) *Logger

WithGin includes the given gin request context in the logger context.

func (*Logger) WithUser

func (l *Logger) WithUser(userID string) *Logger

WithUser includes the given user id in the logger context.

type LoggerMaker

type LoggerMaker interface {
	NewLogger(name string) *Logger
}

type SentryConfig

type SentryConfig struct {
	// DSN to connect with Sentry
	DSN string

	// Environment passed to Sentry
	Environment string

	// Release passed to Sentry
	Release string

	// Log level strings to report messages to Sentry
	LogLevels []string
}

type SentryManager

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

SentryManager is a struct that issues loggers tied back to a central sentry.Hub instance.

func NewSentryManager

func NewSentryManager(config *SentryConfig, logLevel string) (*SentryManager, error)

NewSentryManager creates a SentryManager with a logLevel output minimum.

func (*SentryManager) Fire

func (m *SentryManager) Fire(lEntry *logrus.Entry) error

Fire implements the logrus.Hook interface. Log entries will be logged to Sentry.

func (*SentryManager) Levels

func (m *SentryManager) Levels() []logrus.Level

Levels implements the logrus.Hook interface.

func (*SentryManager) NewLogger

func (m *SentryManager) NewLogger(name string) *Logger

NewLogger returns a Logger with the given name, linked to this SentryManager object

func (*SentryManager) WithRequestContext

func (m *SentryManager) WithRequestContext(ctx *gin.Context)

WithRequestContext issues a new sentry.Hub and sets the Hub's current request to req. To be used in gin.Use as middleware.

Jump to

Keyboard shortcuts

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