logging

package
v0.0.0-...-7ed3587 Latest Latest
Warning

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

Go to latest
Published: Feb 21, 2023 License: MIT Imports: 8 Imported by: 1

Documentation

Overview

Package logging is a local wrapper around logrus package if, suddenly, logrus will become deprecated module it will be easy to move to another solution

Index

Constants

View Source
const (
	// StartDepth is a depth of stack trace,
	// because of log-wrapper, which is used here
	// this start depth is required to find caller correctly.
	StartDepth int = 2
	// PathLen is a count of the directories to log, including file itself.
	PathLen int = 2
	// DefaultFileNameLineKey is a field name in a logged record.
	DefaultFileNameLineKey string = "where"
)

Variables

This section is empty.

Functions

func LogBoundaries

func LogBoundaries(ctx context.Context, req interface{}, info *grpc.UnaryServerInfo, handler grpc.UnaryHandler) (
	resp interface{}, err error,
)

func WithContext

func WithContext(ctx context.Context, logger Logger) context.Context

WithContext puts logger to the context.

func WithLogger

func WithLogger(logger Logger) grpc.UnaryServerInterceptor

func WithUniqTraceID

func WithUniqTraceID(ctx context.Context, req interface{}, info *grpc.UnaryServerInfo, handler grpc.UnaryHandler) (
	resp interface{}, err error,
)

Types

type Fields

type Fields log.Fields

Fields is a wrapper around logrus.Field.

type FileLineHook

type FileLineHook struct {
	LogKeyName string `json:"field_name" yaml:"field_name"` //nolint:tagliatelle,lll // temporary disabled. need to reconcile json/yaml field and struct's field
}

FileLineHook contains caller's log settings.

func GetFileLineHook

func GetFileLineHook() *FileLineHook

GetFileLineHook prepares and returns filename line hook.

func (*FileLineHook) Fire

func (hook *FileLineHook) Fire(entry *log.Entry) error

Fire implements logrus's Hook interface.

func (*FileLineHook) Levels

func (hook *FileLineHook) Levels() []log.Level

Levels implements logrus's Hook interface.

type Logger

type Logger interface {
	Trace(...interface{})
	Debug(...interface{})
	Info(...interface{})
	Warn(...interface{})
	Error(...interface{})
	Fatal(...interface{})
	WithError(err error) Logger
	WithField(key string, value interface{}) Logger
	WithFields(fields Fields) Logger
}

Logger interface.

func FromContext

func FromContext(ctx context.Context) Logger

FromContext extracts Logger from context and returns itself otherwise, creates default one logger.

func GetLogger

func GetLogger() Logger

GetLogger is a Logger getter with default settings.

Jump to

Keyboard shortcuts

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