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
- func LogBoundaries(ctx context.Context, req interface{}, info *grpc.UnaryServerInfo, ...) (resp interface{}, err error)
- func WithContext(ctx context.Context, logger Logger) context.Context
- func WithLogger(logger Logger) grpc.UnaryServerInterceptor
- func WithUniqTraceID(ctx context.Context, req interface{}, info *grpc.UnaryServerInfo, ...) (resp interface{}, err error)
- type Fields
- type FileLineHook
- type Logger
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 ¶
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 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 ¶
FromContext extracts Logger from context and returns itself otherwise, creates default one logger.
Click to show internal directories.
Click to hide internal directories.