logger

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Feb 16, 2017 License: GPL-3.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const LOG_EXTENSION = ".log"

The file extension to use for all new log files that are created

Variables

This section is empty.

Functions

func StandardLogger

func StandardLogger(logBaseName string) error

StandardLogger will return a Logger struct which will hoard a massive amount of logs and messages. Recommended for systems with a healthy amount of free disk space. Logs can be left unchecked for up to 7 days before they're pruned. If you don't want to check them and you don't want to lose them then make sure you download them via REST otherwise you'll miss log data.

Types

type Logger

type Logger struct {
	MaxLogFileCount    uint64 // The maximum number of log files saved to disk before pruning occurs
	MaxLogMessageCount uint64 // The maximum number of bytes a log file can take up before it's cut off and a new one is created
	MaxLogDuration     uint64 // The maximum number of seconds a log can exist for before it's cut off and a new one is created
	// contains filtered or unexported fields
}

Logger allows for aggressive log management in scenarios where disk space might be limited. You can limit based on log message count or duration and also prune log files when too many are saved on disk.

var Lgr *Logger

func CustomLogger

func CustomLogger(logBaseName string, maxFileCount uint64, maxMessageCount uint64, maxDuration uint64) (*Logger, error)

CustomLogger returns a logger with the given variables customized to your liking. Smaller values are better for devices with less free space and vice versa for devices with more free space.

func (*Logger) CurrentLogContents

func (lgr *Logger) CurrentLogContents() ([]byte, error)

CurrentLogContents returns the contents of the current log file that's being managed by the logger instance. The current log should be active thus multiple calls to CurrentLogContents() should give different results assuming the log is being actively written to.

func (*Logger) CurrentLogFile

func (lgr *Logger) CurrentLogFile() *os.File

CurrentLogFile returns a pointer to the current os.File representation of the current log file that is being written to. If this reference is held log enough it can become invalid if the log file is pruned from the disk.

func (*Logger) CurrentLogName

func (lgr *Logger) CurrentLogName() (string, error)

CurrentLogName returns the name of the file which contains the most current log output. This log will be active and likely changing frequently.

func (*Logger) LogMessage

func (lgr *Logger) LogMessage(formatString string, values ...interface{})

LogMessage will write the given string to the current active log file. It will then perform all the necessary checks to make sure that the max number of messages, the max duration of the log file, and the maximum number of overall log files has not been reached. If any of the above parameters have been tripped, action will be taken accordingly.

func (*Logger) Write

func (lgr *Logger) Write(p []byte) (n int, err error)

Write satisfies the writer interface for golang. This allows an instance of Logger to be passed in to the os/exec library for capturing from both the stdout and stderr steams.

Jump to

Keyboard shortcuts

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