Skip to content
Snippets Groups Projects

V.0.1.0 Codename Threadbare

Closed Ghost User requested to merge v.0.1.0-codename-threadbare into master
4 files
+ 73
47
Compare changes
  • Side-by-side
  • Inline
Files
4
+ 56
25
@@ -58,8 +58,8 @@ func get() *Logger {
return logger
}
//Loglevel sets the verbosity of the logger
//Defaults to INFO
// Loglevel sets the verbosity of the logger
// Defaults to INFO
func Loglevel(level Level) {
l := get()
l.lock.Lock()
@@ -67,8 +67,8 @@ func Loglevel(level Level) {
l.Loglevel = level
}
//Output defines the output of the logger
//Defaults to os.Stderr
// Output defines the output of the logger
// Defaults to os.Stderr
func Output(out io.Writer) {
l := get()
l.lock.Lock()
@@ -76,8 +76,8 @@ func Output(out io.Writer) {
l.DefaultWriter = out
}
//LoglevelOutput defines a special output
//for a certain log level
// LoglevelOutput defines a special output
// for a certain log level
func LoglevelOutput(level Level, out io.Writer) {
l := get()
l.lock.Lock()
@@ -88,44 +88,77 @@ func LoglevelOutput(level Level, out io.Writer) {
}
}
//Debug passes the DEBUG flag and a
//message to the logger
// Debug passes the DEBUG flag and a
// message to the logger
func Debug(args ...interface{}) {
log(DEBUG, args...)
}
//Info passes the INFO flag and a
//message to the logger
// Info passes the INFO flag and a
// message to the logger
func Info(args ...interface{}) {
log(INFO, args...)
}
//Warn passes the WARNING flag and a
//message to the logger
// Warn passes the WARNING flag and a
// message to the logger
func Warn(args ...interface{}) {
log(WARNING, args...)
}
//Error passes the ERROR flag and a
//message to the logger
// Error passes the ERROR flag and a
// message to the logger
func Error(args ...interface{}) {
log(ERROR, args...)
}
//Fatal passes the FATAL flag and a
//message to the logger and calls
//os.Exit(1)
// Fatal passes the FATAL flag and a
// message to the logger and calls
// os.Exit(1)
func Fatal(args ...interface{}) {
log(FATAL, args...)
os.Exit(1)
}
//Panic passes the PANIC flag and a
//message to the logger
//Also calls builtin.panic()
func Panic(args ...interface{}) {
log(PANIC, args...)
panic(args)
// Debugf passes the DEBUG flag,
// a formatted string and a
// message to the logger
func Debugf(format string, args ...interface{}) {
logf(DEBUG, format, args...)
}
// Infof passes the INFO flag,
// a formatted string and and a
// message to the logger
func Infof(format string, args ...interface{}) {
logf(INFO, format, args...)
}
// Warnf passes the WARNING flag,
// a formatted string and and a
// message to the logger
func Warnf(format string, args ...interface{}) {
logf(WARNING, format, args...)
}
// Errorf passes the ERROR flag,
// a formatted string and and a
// message to the logger
func Errorf(format string, args ...interface{}) {
logf(ERROR, format, args...)
}
// Fatalf passes the FATAL flag,
// a formatted string and and a
// message to the logger and calls
// os.Exit(1)
func Fatalf(format string, args ...interface{}) {
logf(FATAL, format, args...)
os.Exit(1)
}
func logf(level Level, format string, args ...interface{}) {
log(level, fmt.Sprintf(format, args...))
}
func log(level Level, args ...interface{}) {
@@ -164,8 +197,6 @@ func callers() (string, int) {
func prefix(level Level) string {
switch level {
case PANIC:
return "PANIC"
case FATAL:
return "FATAL"
case ERROR:
Loading