Documentation ¶
Index ¶
- Variables
- func CompressOldLogs() error
- func Debug(value ...interface{})
- func Debugf(format string, args ...interface{})
- func Error(value ...interface{})
- func Errorf(format string, args ...interface{})
- func GetTimeFormat() string
- func Info(value ...interface{})
- func Infof(format string, args ...interface{})
- func Initialize() (err error)
- func StartLogManagementGoroutine()
- func Stop() error
- func Warn(value ...interface{})
- func Warnf(format string, args ...interface{})
Constants ¶
This section is empty.
Variables ¶
var ( // EnableDebug determines whether Debug() or Debugf() should be enabled. EnableDebug bool = strings.ToLower(os.Getenv("DEBUG")) == "true" // LastLogTime is used to determine whether or not to create a new log file // when processing the queue by comparing the current time to this value. LastLogTime time.Time = time.Now() // ActiveLogFile is the currently open log file which is only to be used // during today. If attempting to log after a new day, a new file should be // opened by the log management Goroutine. ActiveLogFile *os.File = nil // Queue is the currently queue of log messages to be processed. This is // used to prevent race condition while writing to the standard output, as // well as writing to the current log file. Any log method may write to this // channel, but only the log management Goroutine may read from it. Queue chan string = make(chan string) // WhiteColor is the color white. WhiteColor *color.Color = color.New(color.FgHiWhite) // GreenColor is the color green. GreenColor *color.Color = color.New(color.FgHiGreen, color.Bold) // YellowColor is the color yellow. YellowColor *color.Color = color.New(color.FgHiYellow, color.Bold) // RedColor is the color red. RedColor *color.Color = color.New(color.FgHiRed, color.Bold) // BlueColor is the color blue. BlueColor *color.Color = color.New(color.FgHiBlue, color.Bold) // AnsiRegExp is a regular expression for finding all ANSI escape codes in // a string. AnsiRegExp *regexp.Regexp = regexp.MustCompile(`[\\u001b\\u009b][[()#;?]*(?:[0-9]{1,4}(?:;[0-9]{0,4})*)?[0-9A-ORZcf-nqry=><]`) )
Functions ¶
func CompressOldLogs ¶
func CompressOldLogs() error
CompressOldLogs searches the logs directory for any log files that were created any date before today, and compresses them to save space since log files may grow to a very large size.
func Debug ¶
func Debug(value ...interface{})
Debug logs new values to the standard output as well as the log file.
func Debugf ¶
func Debugf(format string, args ...interface{})
Debugf logs new values to the standard output as well as the log file using the formatting string provided.
func Error ¶
func Error(value ...interface{})
Error logs new values to the standard output as well as the log file.
func Errorf ¶
func Errorf(format string, args ...interface{})
Errorf logs new values to the standard output as well as the log file using the formatting string provided.
func GetTimeFormat ¶
func GetTimeFormat() string
GetTimeFormat returns the current time and day of the week used in the start of each line of the logs.
func Info ¶
func Info(value ...interface{})
Info logs new values to the standard output as well as the log file.
func Infof ¶
func Infof(format string, args ...interface{})
Infof logs new values to the standard output as well as the log file using the formatting string provided.
func Initialize ¶
func Initialize() (err error)
Initialize is responsible for creating the logs directory and calling the function that compresses any old logs if this directory already exists.
func StartLogManagementGoroutine ¶
func StartLogManagementGoroutine()
StartLogManagementGoroutine is the Goroutine that processes all log entries and writes them to the current log file.
func Stop ¶
func Stop() error
Stop closes all log files and ends the log management Goroutine. TODO rewrite log manager to allow queue to be empty and processed before the channel is closed and the Goroutine is killed. sync.WaitGroup may be the fix
Types ¶
This section is empty.