README

logrus

logrus logger implementation for go-micro meta logger.

Usage

import (
	"os"
	"github.com/sirupsen/logrus"
	"e.coding.net/nimrc/micro/go-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")
}
Expand ▾ Collapse ▴

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