|
|
@ -16,6 +16,7 @@ package log |
|
|
|
import ( |
|
|
|
import ( |
|
|
|
"flag" |
|
|
|
"flag" |
|
|
|
"fmt" |
|
|
|
"fmt" |
|
|
|
|
|
|
|
"log" |
|
|
|
"net/url" |
|
|
|
"net/url" |
|
|
|
"os" |
|
|
|
"os" |
|
|
|
"runtime" |
|
|
|
"runtime" |
|
|
@ -302,3 +303,16 @@ func Fatalln(args ...interface{}) { |
|
|
|
func Fatalf(format string, args ...interface{}) { |
|
|
|
func Fatalf(format string, args ...interface{}) { |
|
|
|
baseLogger.sourced().Fatalf(format, args...) |
|
|
|
baseLogger.sourced().Fatalf(format, args...) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
type errorLogWriter struct{} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
func (errorLogWriter) Write(b []byte) (int, error) { |
|
|
|
|
|
|
|
baseLogger.sourced().Error(string(b)) |
|
|
|
|
|
|
|
return len(b), nil |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// NewErrorLogger returns a log.Logger that is meant to be used
|
|
|
|
|
|
|
|
// in the ErrorLog field of an http.Server to log HTTP server errors.
|
|
|
|
|
|
|
|
func NewErrorLogger() *log.Logger { |
|
|
|
|
|
|
|
return log.New(&errorLogWriter{}, "", 0) |
|
|
|
|
|
|
|
} |
|
|
|