logrus

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Apr 20, 2023 License: Apache-2.0 Imports: 5 Imported by: 0

README

logrus

logrus logger implementation for go-micro meta logger.

Usage

import (
	"os"
	"github.com/sirupsen/logrus"
	"e.coding.net/nimrc/micro/micro/logger"
)

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

func ExampleWithLogger() {
	l:= logrus.New() // *logrus.Logger
	logger.DefaultLogger = NewLogger(WithLogger(l))
  logger.Infof(logger.InfoLevel, "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