logging

package
v0.0.0-...-8aeb8a1 Latest Latest
Warning

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

Go to latest
Published: Jun 29, 2023 License: MIT Imports: 19 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DDLLogerType      = "ddl-debug"
	QueriesLoggerType = "sql-debug"
)
View Source
const (
	GlobalType = "global"
)

Variables

View Source
var ConfigErr string
View Source
var ConfigWarn string
View Source
var GlobalLogsWriter io.Writer
View Source
var LogLevel = UNKNOWN
View Source
var TokenIDExtractRegexp = regexp.MustCompile("incoming.tok=(.*)-\\d\\d\\d\\d-\\d\\d-\\d\\dT")

TokenIDExtractRegexp is a regex for reading already rotated and closed log files

Functions

func CreateLogWriter

func CreateLogWriter(config *Config) io.Writer

func Debug

func Debug(v ...interface{})

func Debugf

func Debugf(format string, v ...interface{})

func EnsureDir

func EnsureDir(dir string) error

func Error

func Error(v ...interface{})

func Errorf

func Errorf(format string, v ...interface{})

func Fatal

func Fatal(v ...interface{})

func Fatalf

func Fatalf(format string, v ...interface{})

func Info

func Info(v ...interface{})

func Infof

func Infof(format string, v ...interface{})

func InitGlobalLogger

func InitGlobalLogger(writer io.Writer, levelStr string) error

InitGlobalLogger initializes main logger

func InitInMemoryWriter

func InitInMemoryWriter() io.WriteCloser

func IsDirWritable

func IsDirWritable(dir string) bool

func NewPrefixDateTimeProxy

func NewPrefixDateTimeProxy(prefix string, writer io.Writer) io.Writer

func NewRollingWriter

func NewRollingWriter(config *Config) io.WriteCloser

func SystemError

func SystemError(v ...interface{})

func SystemErrorf

func SystemErrorf(format string, v ...interface{})

func Warn

func Warn(v ...interface{})

func Warnf

func Warnf(format string, v ...interface{})

Types

type Config

type Config struct {
	FileName      string
	FileDir       string
	RotationMin   int64
	MaxBackups    int
	MaxFileSizeMb int
	Compress      bool

	RotateOnClose bool
}

func (Config) Validate

func (c Config) Validate() error

type DateTimeWriterProxy

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

func (DateTimeWriterProxy) Write

func (wp DateTimeWriterProxy) Write(bytes []byte) (int, error)

type Dual

type Dual struct {
	FileWriter io.Writer
	Stdout     io.Writer
}

Dual write logs into fileWriter and into stdout as well

func (Dual) Write

func (wp Dual) Write(bytes []byte) (int, error)

type Level

type Level int
const (
	UNKNOWN Level = iota
	DEBUG
	INFO
	WARN
	ERROR
	FATAL
)

func ToLevel

func ToLevel(levelStr string) Level

func (Level) String

func (l Level) String() string

type LoggerConfig

type LoggerConfig struct {
	Path        string `mapstructure:"path" json:"path,omitempty" yaml:"path,omitempty"`
	RotationMin int64  `mapstructure:"rotation_min" json:"rotation_min,omitempty" yaml:"rotation_min,omitempty"`
	MaxBackups  int    `mapstructure:"max_backups" json:"max_backups,omitempty" yaml:"max_backups,omitempty"`
}

type ObjectLogger

type ObjectLogger interface {
	io.Closer
	Consume(event map[string]interface{}, tokenID string)
	ConsumeAny(obj interface{})
}

type PrefixDateTimeProxy

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

func (PrefixDateTimeProxy) Write

func (pwp PrefixDateTimeProxy) Write(bytes []byte) (int, error)

type QueryLogger

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

func NewQueryLogger

func NewQueryLogger(identifier string, ddlWriter io.Writer, queryWriter io.Writer) *QueryLogger

func (*QueryLogger) LogDDL

func (l *QueryLogger) LogDDL(query string)

func (*QueryLogger) LogQuery

func (l *QueryLogger) LogQuery(query string)

func (*QueryLogger) LogQueryWithValues

func (l *QueryLogger) LogQueryWithValues(query string, values []interface{})

type RollingWriterProxy

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

RollingWriterProxy for lumberjack.Logger Rotate() only if file isn't empty

func (*RollingWriterProxy) Close

func (rwp *RollingWriterProxy) Close() error

func (*RollingWriterProxy) Write

func (rwp *RollingWriterProxy) Write(p []byte) (int, error)

type SQLDebugConfig

type SQLDebugConfig struct {
	DDL     *LoggerConfig `mapstructure:"ddl" json:"ddl,omitempty" yaml:"ddl,omitempty"`
	Queries *LoggerConfig `mapstructure:"queries" json:"queries,omitempty" yaml:"queries,omitempty"`
}

type StringWriter

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

func NewStringWriter

func NewStringWriter() *StringWriter

func (*StringWriter) Bytes

func (sw *StringWriter) Bytes() []byte

func (*StringWriter) Close

func (sw *StringWriter) Close() error

func (*StringWriter) String

func (sw *StringWriter) String() string

func (*StringWriter) Write

func (sw *StringWriter) Write(p []byte) (n int, err error)

type TaskLogger

type TaskLogger interface {
	INFO(format string, v ...interface{})
	ERROR(format string, v ...interface{})
	WARN(format string, v ...interface{})
	LOG(format, system string, level Level, v ...interface{})

	//Write is used by Singer
	Write(p []byte) (n int, err error)
}

type WriterMock

type WriterMock struct {
	Data [][]byte
}
var InstanceMock *WriterMock

func (*WriterMock) Close

func (im *WriterMock) Close() (err error)

func (*WriterMock) Write

func (im *WriterMock) Write(dataToWrite []byte) (n int, err error)

Jump to

Keyboard shortcuts

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