xlog

package module
v0.0.0-...-4c7e257 Latest Latest
Warning

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

Go to latest
Published: Jun 14, 2023 License: MIT Imports: 15 Imported by: 0

Documentation

Overview

Package lager is the package for lager

Index

Constants

View Source
const (
	RollingPolicySize = "size"
	LogRotateDate     = 1
	LogRotateSize     = 10
	LogBackupCount    = 7
)

constant values for logrotate parameters

View Source
const (
	//DEBUG is a constant of string type
	DEBUG = "DEBUG"
	INFO  = "INFO"
	WARN  = "WARN"
	ERROR = "ERROR"
	FATAL = "FATAL"
)

Variables

Logger is the global variable for the object of lager.Logger

View Source
var Writers = make(map[string]io.Writer)

Writers is a map

Functions

func CopyFile

func CopyFile(srcFile, destFile string) error

CopyFile copy file

func Debug

func Debug(action string, data ...config.Data)

func Debugf

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

func Error

func Error(action string, err error, data ...config.Data)

func Errorf

func Errorf(err error, format string, args ...interface{})

func EscapPath

func EscapPath(msg string) string

EscapPath escape path

func Fatal

func Fatal(action string, err error, data ...config.Data)

func Fatalf

func Fatalf(err error, format string, args ...interface{})

func FilterFileList

func FilterFileList(path, pat string) ([]string, error)

FilterFileList function for filter file list path : where the file will be filtered pat : regexp pattern to filter the matched file

func Info

func Info(action string, data ...config.Data)

func Infof

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

func Init

func Init() error

func InitWithConfig

func InitWithConfig(passLagerDef *PassLagerCfg) error

func InitWithFile

func InitWithFile(lagerFile string) error

readPassLagerConfigFile is unmarshal the paas lager configuration file(lager.yaml)

func Initialize

func Initialize(writers, loggerLevel, loggerFile, rollingPolicy string, logFormatText bool,
	LogRotateDate, LogRotateSize, LogBackupCount int)

Initialize Build constructs a *Lager.Logger with the configured parameters.

func LagerInit

func LagerInit(c Config)

Init is a function which initializes all config struct variables

func LogRotate

func LogRotate(path string, MaxFileSize int, MaxBackupCount int)

LogRotate function for log rotate path: where log files need rollover MaxFileSize: MaxSize of a file before rotate. By M Bytes. MaxBackupCount: Max counts to keep of a log's backup files.

func NewLogger

func NewLogger(component string) config.Logger

NewLogger is a function

func NewLoggerExt

func NewLoggerExt(component string, appGUID string) config.Logger

NewLoggerExt is a function which is used to write new logs

func RegisterWriter

func RegisterWriter(name string, writer io.Writer)

RegisterWriter is used to register a io writer

func Warn

func Warn(action string, data ...config.Data)

func Warnf

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

Types

type Config

type Config struct {
	LoggerLevel    string
	LoggerFile     string
	Writers        []string
	EnableRsyslog  bool
	RsyslogNetwork string
	RsyslogAddr    string

	LogFormatText bool
}

Config is a struct which stores details for maintaining logs

func DefaultConfig

func DefaultConfig() *Config

DefaultConfig is a function which retuns config object with default configuration

type Lager

type Lager struct {
	Writers        string `yaml:"writers"`
	LoggerLevel    string `yaml:"logger_level"`
	LoggerFile     string `yaml:"logger_file"`
	LogFormatText  bool   `yaml:"log_format_text"`
	RollingPolicy  string `yaml:"rollingPolicy"`
	LogRotateDate  int    `yaml:"log_rotate_date"`
	LogRotateSize  int    `yaml:"log_rotate_size"`
	LogBackupCount int    `yaml:"log_backup_count"`
}

Lager struct for logger parameters

type PassLagerCfg

type PassLagerCfg struct {
	Writers        string `yaml:"writers"`
	LoggerLevel    string `yaml:"logger_level"`
	LoggerFile     string `yaml:"logger_file"`
	LogFormatText  bool   `yaml:"log_format_text"`
	RollingPolicy  string `yaml:"rollingPolicy"`
	LogRotateDate  int    `yaml:"log_rotate_date"`
	LogRotateSize  int    `yaml:"log_rotate_size"`
	LogBackupCount int    `yaml:"log_backup_count"`
}

PassLagerCfg is the struct for lager information(passlager.yaml)

var PassLagerDefinition *PassLagerCfg = DefaultLagerDefinition()

PassLagerDefinition is having the information about loging

func DefaultLagerDefinition

func DefaultLagerDefinition() *PassLagerCfg

writers: file,stdout logger_level: DEBUG logger_file: log/apiserver.log log_format_text: false rollingPolicy: size log_rotate_date: 1 log_rotate_size: 1 log_backup_count: 7

Directories

Path Synopsis
lager

Jump to

Keyboard shortcuts

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