logger

package
v0.0.0-...-0ade494 Latest Latest
Warning

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

Go to latest
Published: Aug 26, 2022 License: AGPL-3.0 Imports: 12 Imported by: 0

Documentation

Overview

Logger Interface Use instance of logger instead of exported functions

usage example

import (

"errors"
"github.com/serviceexchange/server/utils/logger"

)

var log logger.LoggerI = &logger.LoggerT{}

or

var log logger.LoggerI = logger.NewLogger()

...

log.Error(...)

Index

Constants

This section is empty.

Variables

Functions

func GetLoggingConfig

func GetLoggingConfig() map[string]int

func Init

func Init()

Setup sets up the logger initially

func SetModuleLevel

func SetModuleLevel(module, levelStr string) error

SetModuleLevel sets log level for a module and it's children Pass empty string for module parameter for resetting root logging level

Types

type LoggerI

type LoggerI interface {
	IsDebugLevel() bool
	Debug(args ...interface{})
	Info(args ...interface{})
	Warn(args ...interface{})
	Error(args ...interface{})
	Fatal(args ...interface{})
	Debugf(format string, args ...interface{})
	Infof(format string, args ...interface{})
	Warnf(format string, args ...interface{})
	Errorf(format string, args ...interface{})
	Fatalf(format string, args ...interface{})
	LogRequest(req *http.Request)
	Child(s string) LoggerI
}

type LoggerT

type LoggerT struct {
	// contains filtered or unexported fields
}

func NewLogger

func NewLogger() *LoggerT

func (*LoggerT) Child

func (l *LoggerT) Child(s string) LoggerI

func (*LoggerT) Debug

func (l *LoggerT) Debug(args ...interface{})

Debug level logging. Most verbose logging level.

func (*LoggerT) Debugf

func (l *LoggerT) Debugf(format string, args ...interface{})

Debugf does debug level logging similar to fmt.Printf. Most verbose logging level

func (*LoggerT) Error

func (l *LoggerT) Error(args ...interface{})

Error level logging. Use this to log errors which dont immediately halt the application.

func (*LoggerT) Errorf

func (l *LoggerT) Errorf(format string, args ...interface{})

Errorf does error level logging similar to fmt.Printf. Use this to log errors which dont immediately halt the application.

func (*LoggerT) Fatal

func (l *LoggerT) Fatal(args ...interface{})

Fatal level logging. Use this to log errors which crash the application.

func (*LoggerT) Fatalf

func (l *LoggerT) Fatalf(format string, args ...interface{})

Fatalf does fatal level logging similar to fmt.Printf. Use this to log errors which crash the application.

func (*LoggerT) Info

func (l *LoggerT) Info(args ...interface{})

Info level logging. Use this to log the state of the application. Dont use Logger.Info in the flow of individual events. Use Logger.Debug instead.

func (*LoggerT) Infof

func (l *LoggerT) Infof(format string, args ...interface{})

Infof does info level logging similar to fmt.Printf. Use this to log the state of the application. Dont use Logger.Info in the flow of individual events. Use Logger.Debug instead.

func (*LoggerT) IsDebugLevel

func (l *LoggerT) IsDebugLevel() bool

IsDebugLevel Returns true is debug lvl is enabled

func (*LoggerT) LogRequest

func (l *LoggerT) LogRequest(req *http.Request)

LogRequest reads and logs the request body and resets the body to original state.

func (*LoggerT) Warn

func (l *LoggerT) Warn(args ...interface{})

Warn level logging. Use this to log warnings

func (*LoggerT) Warnf

func (l *LoggerT) Warnf(format string, args ...interface{})

Warnf does warn level logging similar to fmt.Printf. Use this to log warnings

type NOP

type NOP struct{}

func (NOP) Child

func (NOP) Child(_ string) LoggerI

func (NOP) Debug

func (NOP) Debug(_ ...interface{})

func (NOP) Debugf

func (NOP) Debugf(_ string, _ ...interface{})

func (NOP) Error

func (NOP) Error(_ ...interface{})

func (NOP) Errorf

func (NOP) Errorf(_ string, _ ...interface{})

func (NOP) Fatal

func (NOP) Fatal(_ ...interface{})

func (NOP) Fatalf

func (NOP) Fatalf(_ string, _ ...interface{})

func (NOP) Info

func (NOP) Info(_ ...interface{})

func (NOP) Infof

func (NOP) Infof(_ string, _ ...interface{})

func (NOP) IsDebugLevel

func (NOP) IsDebugLevel() bool

func (NOP) LogRequest

func (NOP) LogRequest(_ *http.Request)

func (NOP) Warn

func (NOP) Warn(_ ...interface{})

func (NOP) Warnf

func (NOP) Warnf(_ string, _ ...interface{})

Jump to

Keyboard shortcuts

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