Documentation
¶
Index ¶
- Constants
- func Check(level string) bool
- func CloseLogger() error
- func Debug(mes string, args ...interface{})
- func Error(mes string, args ...interface{})
- func ErrorAsInfo(err error, args ...interface{})
- func GetCaller(depth int) string
- func GetCallerShort(depth int) string
- func GetTimestampStr() string
- func GlobalZapLogger() *zap.Logger
- func Info(mes string, args ...interface{})
- func Log(level string, depth int, mes string, args ...interface{})
- func NewFileLogger(cfg FileConfig, globalFileName string) *lumberjack.Logger
- func SetGlobalConfig(cfg Config) (err error)
- func SetStdFilterLevel(lev string)
- type Config
- type FileConfig
- type StdConfig
- type WrappedWriteSyncer
- type ZapConfig
- type ZapCoreConfig
- type ZapEncoderConfig
Constants ¶
const LEVEL_DEBUG = "DEBUG"
const LEVEL_DPANIC = "DPANIC"
const LEVEL_ERROR = "ERROR"
const LEVEL_FATAL = "FATAL"
const LEVEL_INFO = "INFO"
const LEVEL_PANIC = "PANIC"
const LEVEL_WARNING = "WARNING"
Variables ¶
This section is empty.
Functions ¶
func ErrorAsInfo ¶
func ErrorAsInfo(err error, args ...interface{})
ErrorAsInfo print error in Info level
func GetCaller ¶
GetCaller returns a Valuer that returns a file and line from a specified depth in the callstack.
func GetCallerShort ¶
GetCallerShort returns a Valuer that returns a file and line from a specified depth in the callstack.
func GlobalZapLogger ¶
func NewFileLogger ¶
func NewFileLogger(cfg FileConfig, globalFileName string) *lumberjack.Logger
NewFileLogger - создать новый логгер в файл
func SetGlobalConfig ¶
SetGlobalConfig - apply new config
Types ¶
type Config ¶
type Config struct {
Enable bool `json:"enable" yaml:"enable"` // состояние логирования 'true', 'false'
GlobalLevel string `json:"global_level" yaml:"global_level"` // debug, info, warn, error, dpanic, panic, fatal - все логгеры ниже этого уровня будут отключены
GlobalFilename string `json:"global_filename" yaml:"global_filename"` // глобальное имя файл для логирования
ZapConfig ZapConfig `json:"zap" yaml:"zap"`
}
Config конфигурация сервиса логирования
func GlobalConfig ¶
func GlobalConfig() Config
type FileConfig ¶
type FileConfig struct {
Filename string `json:"filename" yaml:"filename"` // имя файл для логирования
MaxSize int `json:"max_size" yaml:"max_size"` // максимальный размер лог файла
MaxAge int `json:"max_age" yaml:"max_age"` // время хранения истории лог файлов в днях
MaxBackups int `json:"max_backups" yaml:"max_backups"` // максимальное количество архивных логов
LocalTime bool `json:"local_time" yaml:"local_time"` // использовать локальное время в имени архивных лог файлов
Compress bool `json:"compress" yaml:"compress"` // сжимать архивные лог файлы в zip архив
}
FileConfig
type StdConfig ¶
type StdConfig struct {
Enable bool `json:"enable" yaml:"enable"` // состояние логирования 'true', 'false'
Level string `json:"log_level" yaml:"log_level"` // уровень логирования 'DEBUG', 'INFO', 'ERROR'
LogToFile bool `json:"log_to_file" yaml:"log_to_file"` // логировать в файл 'true', 'false'
LogToStderr bool `json:"log_to_stderr" yaml:"log_to_stderr"` // логировать в stderr 'true', 'false'
LogFlag int `json:"log_flag" yaml:"log_flag"` // флаги настройки вывода лога
LogPrefix string `json:"log_prefix" yaml:"log_prefix"` // префикс строк в лог файл
FileConfig *FileConfig `json:"file" yaml:"file"` // конфигурация для логирования в файл, если имя файла пустое, то используется глобальное
}
StdConfig
type WrappedWriteSyncer ¶
type WrappedWriteSyncer struct {
// contains filtered or unexported fields
}
WrappedWriteSyncer is a helper struct implementing zapcore.WriteSyncer to wrap a standard os.Stdout handle, giving control over the WriteSyncer's Sync() function. Sync() results in an error on Windows in combination with os.Stdout ("sync /dev/stdout: The handle is invalid."). WrappedWriteSyncer simply does nothing when Sync() is called by Zap. https://github.com/uber-go/zap/issues/991
func (WrappedWriteSyncer) Sync ¶
func (mws WrappedWriteSyncer) Sync() error
type ZapConfig ¶
type ZapConfig struct {
Enable bool `json:"enable" yaml:"enable"` // состояние логирования 'true', 'false'
DisableCaller bool `json:"disable_caller,omitempty" yaml:"disable_caller"` // запретить вывод в лог информации о caller
DisableStacktrace bool `json:"disable_stacktrace,omitempty" yaml:"disable_stacktrace"` // запретить вывод в stacktrace
StacktraceLevel string `json:"stacktrace_level" yaml:"stacktrace_level"` // для какого уровня выводить stacktrace debug, info, warn, error, dpanic, panic, fatal
Development bool `json:"development" yaml:"development"` // режим разработки для уровня dpanic
ZapCoreConfig []ZapCoreConfig `json:"core,omitempty" yaml:"core"`
Sampling *zap.SamplingConfig `json:"sampling,omitempty" yaml:"sampling"`
}
ZapConfig
type ZapCoreConfig ¶
type ZapCoreConfig struct {
Enable bool `json:"enable" yaml:"enable"` // состояние логирования 'true', 'false'
MinLevel string `json:"min_level" yaml:"min_level"` // минимальный уровень логирования debug, info, warn, error, dpanic, panic, fatal
MaxLevel string `json:"max_level" yaml:"max_level"` // максимальный уровень логирования debug, info, warn, error, dpanic, panic, fatal
LogTo string `json:"log_to" yaml:"log_to"` // логировать в 'file', 'stderr', 'stdout', 'url', 'lumberjack'
LoggingPath string `json:"logging_path" yaml:"logging_path"` // путь для логирования
Encoding string `json:"encoding,omitempty" yaml:"encoding"` // формат вывода 'console', 'json'
FileConfig *FileConfig `json:"file" yaml:"file"` // конфигурация для логирования в файл, если имя файла пустое, то используется глобальное
EncoderConfig ZapEncoderConfig `json:"encoder_config" yaml:"encoder_config"` // конфигурация Encoder
}
ZapCoreConfig
type ZapEncoderConfig ¶
type ZapEncoderConfig struct {
MessageKey string `json:"message_key,omitempty" yaml:"message_key"`
LevelKey string `json:"level_key,omitempty" yaml:"level_key"`
TimeKey string `json:"time_key,omitempty" yaml:"time_key"`
NameKey string `json:"name_key,omitempty" yaml:"name_key"`
CallerKey string `json:"caller_key,omitempty" yaml:"caller_key"`
FunctionKey string `json:"function_key,omitempty" yaml:"function_key"`
StacktraceKey string `json:"stacktrace_key,omitempty" yaml:"stacktrace_key"`
SkipLineEnding bool `json:"skip_line_ending,omitempty" yaml:"skip_line_ending"`
LineEnding string `json:"line_ending,omitempty" yaml:"line_ending"`
EncodeLevel string `json:"encode_level,omitempty" yaml:"encode_level"` // capital, capitalColor, color, lower
EncodeTime string `json:"encode_time,omitempty" yaml:"encode_time"` // rfc3339nano, rfc3339, iso8601, millis, nanos
EncodeTimeCustom string `json:"encode_time_custom,omitempty" yaml:"encode_time_custom"` // 2006-01-02 15:04:05.000000
EncodeDuration string `json:"encode_duration,omitempty" yaml:"encode_duration"` // string, nanos, ms
EncodeCaller string `json:"encode_caller,omitempty" yaml:"encode_caller"` // full, short
ConsoleSeparator string `json:"console_separator,omitempty" yaml:"console_separator"`
}
ZapEncoderConfig