forked from emicklei/go-restful
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add 'log' package for package-wide logging, expose SetLogger(Logger).
- Loading branch information
Showing
7 changed files
with
100 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
package log | ||
|
||
import ( | ||
stdlog "log" | ||
"os" | ||
) | ||
|
||
// Logger corresponds to a subset of the interface satisfied by stdlib log.Logger | ||
type StdLogger interface { | ||
Fatal(v ...interface{}) | ||
Fatalf(format string, v ...interface{}) | ||
Fatalln(v ...interface{}) | ||
// Flags() int | ||
// Output(calldepth int, s string) error | ||
// Panic(v ...interface{}) | ||
// Panicf(format string, v ...interface{}) | ||
// Panicln(v ...interface{}) | ||
// Prefix() string | ||
Print(v ...interface{}) | ||
Printf(format string, v ...interface{}) | ||
Println(v ...interface{}) | ||
// SetFlags(flag int) | ||
// SetPrefix(prefix string) | ||
} | ||
|
||
var Logger StdLogger | ||
|
||
func init() { | ||
// default Logger | ||
SetLogger(stdlog.New(os.Stdout, "[restful] ", stdlog.LstdFlags|stdlog.Lshortfile)) | ||
} | ||
|
||
func SetLogger(customLogger StdLogger) { | ||
Logger = customLogger | ||
} | ||
|
||
func Fatal(v ...interface{}) { | ||
Logger.Fatal(v...) | ||
} | ||
|
||
func Fatalf(format string, v ...interface{}) { | ||
Logger.Fatalf(format, v...) | ||
} | ||
|
||
func Fatalln(v ...interface{}) { | ||
Logger.Fatalln(v...) | ||
} | ||
|
||
func Print(v ...interface{}) { | ||
Logger.Print(v...) | ||
} | ||
|
||
func Printf(format string, v ...interface{}) { | ||
Logger.Printf(format, v...) | ||
} | ||
|
||
func Println(v ...interface{}) { | ||
Logger.Println(v...) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters