logrus

package module
v0.0.0-...-2ea7ab9 Latest Latest
Warning

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

Go to latest
Published: Sep 5, 2024 License: Apache-2.0 Imports: 5 Imported by: 0

README

logrus

logrus logger implementation for go-admin meta logger.

Usage

import (
	"os"
	"github.com/sirupsen/logrus"
	"gitee.com/linxing_3/youye-core/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

func WithJSONFormatter

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

func WithLevelHooks

func WithLevelHooks(hooks logrus.LevelHooks) logger.Option

func WithLogger

func WithLogger(l logrus.StdLogger) logger.Option

func WithTextTextFormatter

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

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)
}

Jump to

Keyboard shortcuts

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