Documentation
¶
Index ¶
- Constants
- Variables
- func CloseLogHandle(handle LogHandle) error
- func DeInitLogger() []error
- func GetLogDir() string
- func GetLogFile() string
- func GetLogLevel() string
- func GetLogTag() string
- func InitFileLogger(logFile, logLevel string) error
- func InitLogging()
- func InitSysLogger(module, logLevel string) error
- func InitializeLogger(config Config) error
- func IsFileLogger() bool
- func IsSysLogConfigPresent() bool
- func RegisterCommandOptions(f *flag.FlagSet, defaultParams map[string]string)
- type Config
- type ConsoleLogger
- type FileLogHandle
- type LogHandle
- type Logger
- type Type
Constants ¶
const ( FileLog = 1 << iota SysLog )
Below logger types are supported.
const SyslogTagPrefix = "vxos-asum@"
SyslogTagPrefix defines tag name for syslog.
Variables ¶
var ( //ConsoleDebug logger for console and log Debug messages. ConsoleDebug ConsoleLogger //ConsoleInfo logger for console and log Info messages. ConsoleInfo ConsoleLogger //ConsoleWarning logger for console and log Warning messages. ConsoleWarning ConsoleLogger //ConsoleError logger for console and log Error messages. ConsoleError ConsoleLogger //Debug logger for logging Debug messages. Debug *log.Logger //Info logger for logging Info messages. Info *log.Logger //Warning logger for logging Warning messages. Warning *log.Logger //Error logger for logging Error messages. Error *log.Logger )
var DefaultLogDir = "/var/log/asum/"
DefaultLogDir used before reading conf file or cmdline params, and could be overridden by conf file or cmdline params.
var DefaultLogFile = progname + ".log"
DefaultLogFile used before reading conf file or cmdline params, and could be overriden by conf file or cmdline params
var DefaultLogLevel = "INFO"
DefaultLogLevel used in case if it's not specified in config or cmdline.
var DefaultLogPath = DefaultLogDir + DefaultLogFile
DefaultLogPath used in case if path to log file is not specified in config or cmdline.
Functions ¶
func CloseLogHandle ¶ added in v1.0.4
CloseLogHandle closes log handler
func DeInitLogger ¶ added in v1.0.4
func DeInitLogger() []error
DeInitLogger closes the log file and syslog handler
func GetLogDir ¶ added in v1.0.4
func GetLogDir() string
GetLogDir provides location for storing logs.
func InitFileLogger ¶ added in v1.0.4
InitFileLogger initializes logger with given log level.
func InitLogging ¶ added in v1.0.4
func InitLogging()
InitLogging initializes logging to use syslog when its config exists, or to use file logging automatically. This setting might be overridden after reading config or cmdline parameters and by calling InitializeLogger().
func InitSysLogger ¶ added in v1.0.4
InitSysLogger initializes logger with given log level.
func InitializeLogger ¶ added in v1.0.4
InitializeLogger initializes customized file logger or syslog logger with given log config
func IsFileLogger ¶ added in v1.0.4
func IsFileLogger() bool
IsFileLogger returns true if file log is initialized (and not syslog)
func IsSysLogConfigPresent ¶ added in v1.0.4
func IsSysLogConfigPresent() bool
IsSysLogConfigPresent indicates whether syslog config is present.
Types ¶
type Config ¶ added in v1.0.4
type Config struct {
// contains filtered or unexported fields
}
Config is used to track user defined configuration.
func FileLogConfig ¶ added in v1.0.4
FileLogConfig Setup FileLog Config
func SyslogConfig ¶ added in v1.0.4
SyslogConfig Setup SysLog Config
type ConsoleLogger ¶ added in v1.0.4
type ConsoleLogger struct {
// contains filtered or unexported fields
}
ConsoleLogger will print message on screen and write to log file The message will always be printed regardless the log level The writing action depends on the log level
func (*ConsoleLogger) PrintNReturnError ¶ added in v1.0.4
func (consoleLog *ConsoleLogger) PrintNReturnError(msg string, args ...interface{}) error
PrintNReturnError calls Printf and returns wrapped message as error
func (*ConsoleLogger) Printf ¶ added in v1.0.4
func (consoleLog *ConsoleLogger) Printf(msg string, args ...interface{})
Printf prints message in console and writes to log file
type FileLogHandle ¶ added in v1.0.4
type FileLogHandle struct {
// contains filtered or unexported fields
}
FileLogHandle the file log handler
func (*FileLogHandle) Close ¶ added in v1.0.4
func (handle *FileLogHandle) Close() error
Close close the FileLog handler.
type Logger ¶ added in v1.0.4
type Logger struct {
// contains filtered or unexported fields
}
Logger implements functions for all log levels