Documentation
¶
Index ¶
- Constants
- func DeleteEmptyAndOldLogs() error
- func DeleteLogsOnCond(condToSkip func(os.FileInfo) bool) error
- func LogChanErrors(level int, errChan chan error) (bool, []error)
- func LogError(err error, level int)
- func LogErrors(level int, errs ...error) bool
- func LogMessageToPath(message, filePath string, level int)
- type Logger
- func (l Logger) Debug(message string)
- func (l Logger) Debugf(format string, args ...any)
- func (l Logger) Error(message string)
- func (l Logger) Errorf(format string, args ...any)
- func (l Logger) Fatal(message string)
- func (l Logger) Fatalf(format string, args ...any)
- func (l Logger) Info(message string)
- func (l Logger) Infof(format string, args ...any)
- func (l Logger) LogBasedOnLvl(lvl int, msg string)
- func (l Logger) LogBasedOnLvlf(lvl int, format string, args ...any)
- func (l Logger) Print(message string)
- func (l Logger) Printf(format string, args ...any)
- func (l Logger) SetOutput(w io.Writer)
- func (l Logger) Trace(message string)
- func (l Logger) Tracef(format string, args ...any)
- func (l Logger) Warning(message string)
- func (l Logger) Warningf(format string, args ...any)
Constants ¶
const ( LOG_SUFFIX = "\n\n" LOG_PERMS = 0644 // rw-r--r-- LOG_THRESHOLD = 15 * 24 * time.Hour )
const ( // Log levels TRACE = iota DEBUG INFO WARNING ERROR FATAL )
Variables ¶
This section is empty.
Functions ¶
func DeleteEmptyAndOldLogs ¶
func DeleteEmptyAndOldLogs() error
Delete all empty log files and log files older than the log threshold except for the current day's log file.
func DeleteLogsOnCond ¶ added in v1.1.2
func LogChanErrors ¶
Uses the thread-safe LogError() function to log a channel of errors
Also returns if any errors were due to context.Canceled which is caused by Ctrl + C.
func LogError ¶
Thread-safe logging function that logs to "cultured_downloader.log" in the logs directory
func LogErrors ¶
Uses the thread-safe LogError() function to log multiple errors
Also returns if any errors were due to context.Canceled which is caused by Ctrl + C.
func LogMessageToPath ¶
Thread-safe logging function that logs to the provided file path
Types ¶
type Logger ¶
type Logger struct {
// contains filtered or unexported fields
}
var (
MainLogger Logger
)
func (Logger) LogBasedOnLvl ¶
LogBasedOnLvl is a wrapper for LogBasedOnLvlf() that takes a string instead of a format string
However, please ensure that the lvl passed in is valid (i.e. INFO, ERROR, or DEBUG), otherwise this function will panic
func (Logger) LogBasedOnLvlf ¶
LogBasedOnLvlf logs a message based on the log level passed in
You can use this function to log a message with a format string ¶
However, please ensure that the lvl passed in is valid (i.e. TRACE, DEBUG, etc.), otherwise this function will panic