1
0
Fork 0
mirror of https://github.com/Luzifer/s3sync.git synced 2024-12-20 19:41:15 +00:00

Added documentation

This commit is contained in:
Knut Ahlers 2015-07-28 16:09:42 +02:00
parent 1675060782
commit 6c5e7c4e0c

View file

@ -2,8 +2,10 @@ package logger
import "fmt" import "fmt"
// LogLevel defines a type for named log levels
type LogLevel uint type LogLevel uint
// Pre-Defined log levels to be used with this logging module
const ( const (
Error LogLevel = iota Error LogLevel = iota
Warning Warning
@ -16,32 +18,38 @@ type Logger struct {
Level LogLevel Level LogLevel
} }
// New instanciates a new Logger and sets the preferred log level
func New(logLevel LogLevel) *Logger { func New(logLevel LogLevel) *Logger {
return &Logger{ return &Logger{
Level: logLevel, Level: logLevel,
} }
} }
// Log is the filtered equivalent to fmt.Println
func (l *Logger) Log(level LogLevel, line string) { func (l *Logger) Log(level LogLevel, line string) {
if l.Level >= level { if l.Level >= level {
fmt.Println(line) fmt.Println(line)
} }
} }
// LogF is the filtered equivalent to fmt.Printf
func (l *Logger) LogF(level LogLevel, line string, args ...interface{}) { func (l *Logger) LogF(level LogLevel, line string, args ...interface{}) {
if l.Level >= level { if l.Level >= level {
fmt.Printf(line, args...) fmt.Printf(line, args...)
} }
} }
// ErrorF executes LogF with Error level
func (l *Logger) ErrorF(line string, args ...interface{}) { func (l *Logger) ErrorF(line string, args ...interface{}) {
l.LogF(Error, line, args...) l.LogF(Error, line, args...)
} }
// InfoF executes LogF with Info level
func (l *Logger) InfoF(line string, args ...interface{}) { func (l *Logger) InfoF(line string, args ...interface{}) {
l.LogF(Info, line, args...) l.LogF(Info, line, args...)
} }
// DebugF executes LogF with Debug level
func (l *Logger) DebugF(line string, args ...interface{}) { func (l *Logger) DebugF(line string, args ...interface{}) {
l.LogF(Debug, line, args...) l.LogF(Debug, line, args...)
} }