Documentation
¶
Index ¶
- Constants
- Variables
- func AlterDefaultLogger(conf *Config)
- func Debug(xTxID interface{}, msg string, fields ...Field)
- func Error(xTxID interface{}, msg string, fields ...Field)
- func Info(xTxID interface{}, msg string, fields ...Field)
- func Panic(xTxID interface{}, msg string, fields ...Field)
- func Warn(xTxID interface{}, msg string, fields ...Field)
- type Config
- type ConfigOption
- type Field
- type Formatter
- type Level
- type Logger
Constants ¶
const ( // XTransactionID is a key of transaction ID for microservice. // This is supposed to be set in HTTP header and SQS attributes and so on. // This variable is used in each service. XTransactionID = "X-Transaction-ID" )
Variables ¶
var Formatters = struct { Text Formatter JSON Formatter LTSV Formatter }{ Text: Formatter{Formatter: &logrus.TextFormatter{}}, JSON: Formatter{Formatter: &logrus.JSONFormatter{}}, LTSV: Formatter{Formatter: &logrusltsv.Formatter{}}, }
Formatters is a struct variable for Config.
var Levels = func() levels { const ( Debug Level = iota + 1 Info Warn Error Panic ) return levels{ Debug: Debug, Info: Info, Warn: Warn, Error: Error, Panic: Panic, } }()
Levels provides levels of logging Debug Info Warn Error Panic Fatal
var ( // ServiceName is supposed to be embedded by using // ldflags at build time of a service application. ServiceName = "not-set" )
Functions ¶
func AlterDefaultLogger ¶
func AlterDefaultLogger(conf *Config)
AlterDefaultLogger changes default logger by the given config. This affects logger.Debug, Info, Warn, Error methods.
Types ¶
type Config ¶
type Config struct {
// contains filtered or unexported fields
}
Config is a configuration structure for Logger.
formatter: Format type of logging, TEXT or JSON, or LTSV out: io.Writer of the logger output minLevel: Minimum level to out
func NewConfig ¶
func NewConfig(options ...ConfigOption) *Config
NewConfig is a constructor of *Config.
Default setting as Microservice rule Formatter: LTSV Out: stdout MinLevel: Info
type ConfigOption ¶
type ConfigOption func(*Config)
ConfigOption is a type of function to set the fields of Config for Functional Options Pattern.
func WithFormatter ¶
func WithFormatter(formatter Formatter) ConfigOption
WithFormatter - specify format type of logger.
func WithMinLevel ¶
func WithMinLevel(minLevel Level) ConfigOption
WithMinLevel - specify Logging minimum level.
func WithOut ¶
func WithOut(out io.Writer) ConfigOption
WithOut - specify output destination of logger.
type Field ¶
type Field struct {
// contains filtered or unexported fields
}
Field is a struct type for additional fields of Logging.
type Logger ¶
type Logger interface {
Debug(xTxID interface{}, msg string, fields ...Field)
Info(xTxID interface{}, msg string, fields ...Field)
Warn(xTxID interface{}, msg string, fields ...Field)
Error(xTxID interface{}, msg string, fields ...Field)
Panic(xTxID interface{}, msg string, fields ...Field)
}
Logger is public interface of this package.