logging

package
v0.0.0-...-315237c Latest Latest
Warning

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

Go to latest
Published: May 2, 2024 License: MIT Imports: 16 Imported by: 14

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

Functions

func CreateLogWriter

func CreateLogWriter(config *Config) io.Writer

func Debug

func Debug(v ...any)

func Debugf

func Debugf(format string, v ...any)

func EnsureDir

func EnsureDir(dir string) error

func Error

func Error(v ...any)

func Errorf

func Errorf(format string, v ...any)

func Fatal

func Fatal(v ...any)

func Fatalf

func Fatalf(format string, v ...any)

func Info

func Info(v ...any)

func Infof

func Infof(format string, v ...any)

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 SetJsonFormatter

func SetJsonFormatter()

func SetTextFormatter

func SetTextFormatter()

func SystemError

func SystemError(v ...any)

func SystemErrorf

func SystemErrorf(format string, v ...any)

func Warn

func Warn(v ...any)

func Warnf

func Warnf(format string, v ...any)

Types

type Config

type Config struct {
	FileName    string
	FileDir     string
	RotationMin int64
	MaxBackups  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]any, tokenID string)
	ConsumeAny(obj any)
}

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) LogQuery

func (l *QueryLogger) LogQuery(query string, err error, values ...any)

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 ...any)
	ERROR(format string, v ...any)
	WARN(format string, v ...any)
	LOG(format, system string, level Level, v ...any)

	//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