logrus

package module
v0.0.0-...-fdd0fd4 Latest Latest
Warning

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

Go to latest
Published: Nov 18, 2022 License: Apache-2.0 Imports: 5 Imported by: 0

README

Usage

import (
	"os"
	"github.com/sirupsen/logrus"
	"github.com/jwcjf/go-project-base/logger"
)

func ExampleWithOutput() {
	logger.DefaultLogger = NewLogger(logger.WithOutput(os.Stdout))
	logger.Infof("testing: %s", "Infof")
}

func ExampleWithLogger() {
	l := logrus.New() // *logrus.Logger
	logger.DefaultLogger = NewLogger(WithLogger(l))
	logger.Infof("testing: %s", "Infof")
}

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewLogger

func NewLogger(opts ...logger.Option) logger.Logger

New builds a new logger based on options

func ReportCaller

func ReportCaller() logger.Option

warning to use this option. because logrus doest not open CallerDepth option this will only print this package

func WithExitFunc

func WithExitFunc(exit func(int)) logger.Option

WithExitFunc ...

func WithJSONFormatter

func WithJSONFormatter(formatter *logrus.JSONFormatter) logger.Option

WithJSONFormatter ...

func WithLevelHooks

func WithLevelHooks(hooks logrus.LevelHooks) logger.Option

WithLevelHooks ...

func WithLogger

func WithLogger(l logrus.StdLogger) logger.Option

WithLogger ...

func WithTextTextFormatter

func WithTextTextFormatter(formatter *logrus.TextFormatter) logger.Option

WithTextTextFormatter ...

Types

type Options

type Options struct {
	logger.Options
	Formatter logrus.Formatter
	Hooks     logrus.LevelHooks
	// Flag for whether to log caller info (off by default)
	ReportCaller bool
	// Exit Function to call when FatalLevel log
	ExitFunc func(int)
}

Options ...

Jump to

Keyboard shortcuts

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