logger

package
v0.3.1 Latest Latest
Warning

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

Go to latest
Published: Feb 17, 2020 License: MIT Imports: 8 Imported by: 5

Documentation

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

func InitLogger

func InitLogger(cfg config.LogConfiguration)
Example
package main

import (
	"os"

	mlog "github.com/micro/go-micro/v2/logger"
	zlog "github.com/micro/go-plugins/logger/zerolog/v2"
	"github.com/rs/zerolog"
	"github.com/rs/zerolog/pkgerrors"
	"github.com/xmlking/micro-starter-kit/shared/micro/logger/stackdriver"
)

func main() {
	zerolog.ErrorStackMarshaler = pkgerrors.MarshalStack
	zerolog.LevelFieldName = "severity"
	zerolog.TimestampFieldName = "timestamp"
	mLogger := zlog.NewLogger(
		zlog.WithOut(os.Stdout),
		zlog.UseAsDefault(),
		zlog.WithProductionMode(),
		zlog.WithHooks([]zerolog.Hook{stackdriver.StackdriverSeverityHook{}}),
		zlog.WithTimeFormat("aaa"),
	)
	mlog.Register(mLogger)
	logr, _ := mlog.GetLogger("zerolog")
	logr.Log(mlog.InfoLevel, "Hello World")
}
Output:

{"severity":"info","timestamp":"aaa","severity":"Info","message":"Hello World"}

func NewLogger

func NewLogger(cfg config.LogConfiguration) logger.Logger

NewLogger create new logger from config and return Logger interface log level: panic, fatal, error, warn, info, debug, trace log runtime: dev, prod, gcp, azure, aws

Types

This section is empty.

Jump to

Keyboard shortcuts

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