gplog

package
v1.0.12 Latest Latest
Warning

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

Go to latest
Published: Dec 1, 2023 License: Apache-2.0 Imports: 8 Imported by: 10

Documentation

Index

Constants

View Source
const (
	/*
	 * The following constants representing the current logging level, and are
	 * cumulative (that is, setting the log level to Debug will print all Error-,
	 * Info-, and Verbose-level messages in addition to Debug-level messages).
	 *
	 * Log levels for terminal output and logfile output are separate, and can be
	 * set independently.  By default, a new logger will have a verbosity of INFO
	 * for terminal output and DEBUG for logfile output.
	 */
	LOGERROR = iota
	LOGINFO
	LOGVERBOSE
	LOGDEBUG
)

Variables

This section is empty.

Functions

func Debug

func Debug(s string, v ...interface{})

func Error

func Error(s string, v ...interface{})

func Fatal

func Fatal(err error, s string, v ...interface{})

func FatalOnError

func FatalOnError(err error, output ...string)

func FatalWithoutPanic

func FatalWithoutPanic(s string, v ...interface{})

func GenerateLogFileName

func GenerateLogFileName(program, logdir string) string

func GetErrorCode

func GetErrorCode() int

func GetHeader

func GetHeader(program string) string

func GetLogFilePath

func GetLogFilePath() string

func GetLogFileVerbosity

func GetLogFileVerbosity() int

func GetLogPrefix

func GetLogPrefix(level string) string

func GetVerbosity

func GetVerbosity() int

func Info

func Info(s string, v ...interface{})

func InitializeLogging

func InitializeLogging(program string, logdir string)

* Multiple calls to InitializeLogging can be made if desired; the first call * will initialize the logger as a singleton and subsequent calls will return * the same Logger instance.

func SetErrorCode

func SetErrorCode(code int)

func SetExitFunc

func SetExitFunc(pExitFunc func())

func SetLogFileNameFunc

func SetLogFileNameFunc(fileNameFunc func(string, string) string)

func SetLogFileVerbosity

func SetLogFileVerbosity(verbosity int)

func SetLogPrefixFunc

func SetLogPrefixFunc(logPrefixFunc func(string) string)

func SetLogger

func SetLogger(log *GpLogger)

func SetVerbosity

func SetVerbosity(verbosity int)

func Verbose

func Verbose(s string, v ...interface{})

func Warn

func Warn(s string, v ...interface{})

Types

type ExitFunc

type ExitFunc func()

type GpLogger

type GpLogger struct {
	// contains filtered or unexported fields
}

func GetLogger

func GetLogger() *GpLogger

This function should only be used for testing purposes

func NewLogger

func NewLogger(stdout io.Writer, stderr io.Writer, logFile io.Writer, logFileName string, shellVerbosity int, program string, logFileVerbosity ...int) *GpLogger

stdout and stderr are passed in to this function to enable output redirection in tests.

type LogFileNameFunc

type LogFileNameFunc func(string, string) string

type LogPrefixFunc

type LogPrefixFunc func(string) string

* Leveled logging output functions using the above log levels are implemented * below. Info(), Verbose(), and Debug() print messages when the log level is * set at or above the log level matching their names. Warn(), Error(), and * Fatal() always print their messages regardless of the current log level. * * The intended usage of these functions is as follows: * - Info: Messages that should always be written unless the user explicitly * suppresses output, e.g. notifying the user that a step has completed. * - Verbose: More detailed messages that are mostly useful to the user, e.g. * printing information about a function's substeps for progress tracking. * - Debug: More detailed messages that are mostly useful to developers, e.g. * noting that a function has been called with certain arguments. * - Warn: Messages indicating unusual but not incorrect behavior that a user * may want to know, e.g. that certain steps are skipped when using * certain flags. These messages are shown even if output is suppressed. * - Error: Messages indicating that an error has occurred, but that the program * can continue, e.g. one function call in a group failed but others succeeded. * - Fatal: Messages indicating that the program cannot proceed, e.g. the database * cannot be reached. This function will exit the program after printing * the error message. * - FatalWithoutPanic: Same as Fatal, but will not trigger panic. Just exit(1).

Jump to

Keyboard shortcuts

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