Documentation ¶
Index ¶
- Constants
- func Debug(format string, args ...interface{})
- func Error(format string, args ...interface{})
- func GetLogFileForProcess(execName string) (*os.File, error)
- func Info(format string, args ...interface{})
- func Init(logpath string, maxfiles, nfilesToDel int, maxsize uint32, logDebug bool) error
- func SetFilenamePrefix(logfilenamePrefix string) error
- func SetLogFilenameLineNum(on bool)
- func SetLogFunctionName(on bool)
- func SetLogToConsole(on bool)
- func Warn(format string, args ...interface{})
Constants ¶
const ( // Default filename prefix for logfiles //DefFilenamePrefix = "%P.%H.%U" DefFilenamePrefix = "%P" )
const strings
Variables ¶
This section is empty.
Functions ¶
func Debug ¶
func Debug(format string, args ...interface{})
Debug logs down a log with Debug level. If parameter logDebug of logger.Init() is set to be false, no Debug logs will be logged down.
func GetLogFileForProcess ¶
GetLogFileForProcess provides a opened file for logging process output
func Init ¶
Init must be called first, otherwise this logger will not function properly! It returns nil if all goes well, otherwise it returns the corresponding error.
maxfiles: Must be greater than 0 and less than or equal to 100000. nfilesToDel: Number of files deleted when number of log files reaches `maxfiles`. Must be greater than 0 and less than or equal to `maxfiles`. maxsize: Maximum size of a log file in MB, 0 means unlimited. logDebug: If set to false, `logger.Debug("xxxx")` will be mute.
func SetFilenamePrefix ¶
SetFilenamePrefix sets filename prefix for the logfiles.
Filename format for logfiles is `PREFIX`.`SEVERITY_LEVEL`.`DATE_TIME`.log 3 kinds of placeholders can be used in the prefix: %P, %H and %U. %P means program name, %H means hostname, %U means username. The default prefix for a log filename is logger.DefFilenamePrefix ("%P.%H.%U").
func SetLogFilenameLineNum ¶
func SetLogFilenameLineNum(on bool)
SetLogFilenameLineNum sets whether to log down the filename and line number where the log takes place. By default, filename and line number are logged down. You can turn it off for better performance.
func SetLogFunctionName ¶
func SetLogFunctionName(on bool)
SetLogFunctionName sets whether to log down the function name where the log takes place. By default, function name is not logged down for better performance.
func SetLogToConsole ¶
func SetLogToConsole(on bool)
SetLogToConsole sets whether to output logs to the console. By default, logs are not output to the console.
Types ¶
This section is empty.