Documentation ¶
Index ¶
- Constants
- func Error(v ...interface{})
- func Errorf(format string, v ...interface{})
- func Errorln(v ...interface{})
- func Fatal(v ...interface{})
- func Fatalf(format string, v ...interface{})
- func Fatalln(v ...interface{})
- func Flags() int
- func FormatTimestamp(ts time.Time) string
- func Panic(v ...interface{})
- func Panicf(format string, v ...interface{})
- func Panicln(v ...interface{})
- func Print(v ...interface{})
- func PrintAuthf(username string, req *http.Request, status AuthStatus, format string, ...)
- func PrintReq(username, upstream string, req *http.Request, url url.URL, ts time.Time, ...)
- func Printf(format string, v ...interface{})
- func Println(v ...interface{})
- func SetAuthEnabled(e bool)
- func SetAuthTemplate(t string)
- func SetErrOutput(w io.Writer)
- func SetErrToInfo(e bool)
- func SetExcludePaths(s []string)
- func SetFlags(flag int)
- func SetGetClientFunc(f GetClientFunc)
- func SetOutput(w io.Writer)
- func SetReqEnabled(e bool)
- func SetReqTemplate(t string)
- func SetStandardEnabled(e bool)
- func SetStandardTemplate(t string)
- type AuthStatus
- type GetClientFunc
- type Level
- type Logger
- func (l *Logger) Flags() int
- func (l *Logger) FormatTimestamp(ts time.Time) string
- func (l *Logger) GetFileLineString(calldepth int) string
- func (l *Logger) Output(lvl Level, calldepth int, message string)
- func (l *Logger) PrintAuthf(username string, req *http.Request, status AuthStatus, format string, ...)
- func (l *Logger) PrintReq(username, upstream string, req *http.Request, url url.URL, ts time.Time, ...)
- func (l *Logger) SetAuthEnabled(e bool)
- func (l *Logger) SetAuthTemplate(t string)
- func (l *Logger) SetErrToInfo(e bool)
- func (l *Logger) SetExcludePaths(s []string)
- func (l *Logger) SetFlags(flag int)
- func (l *Logger) SetGetClientFunc(f GetClientFunc)
- func (l *Logger) SetReqEnabled(e bool)
- func (l *Logger) SetReqTemplate(t string)
- func (l *Logger) SetStandardEnabled(e bool)
- func (l *Logger) SetStandardTemplate(t string)
Constants ¶
const ( // DefaultStandardLoggingFormat defines the default standard log format DefaultStandardLoggingFormat = "[{{.Timestamp}}] [{{.File}}] {{.Message}}" // DefaultAuthLoggingFormat defines the default auth log format DefaultAuthLoggingFormat = "{{.Client}} - {{.RequestID}} - {{.Username}} [{{.Timestamp}}] [{{.Status}}] {{.Message}}" // DefaultRequestLoggingFormat defines the default request log format DefaultRequestLoggingFormat = "" /* 204-byte string literal not displayed */ // AuthSuccess indicates that an auth attempt has succeeded explicitly AuthSuccess AuthStatus = "AuthSuccess" // AuthFailure indicates that an auth attempt has failed explicitly AuthFailure AuthStatus = "AuthFailure" // AuthError indicates that an auth attempt has failed due to an error AuthError AuthStatus = "AuthError" // Llongfile flag to log full file name and line number: /a/b/c/d.go:23 Llongfile = 1 << iota // Lshortfile flag to log final file name element and line number: d.go:23. overrides Llongfile Lshortfile // LUTC flag to log UTC datetime rather than the local time zone LUTC // LstdFlags flag for initial values for the logger LstdFlags = Lshortfile // DEFAULT is the default log level (effectively INFO) DEFAULT Level = iota // ERROR is for error-level logging ERROR )
Variables ¶
This section is empty.
Functions ¶
func Error ¶
func Error(v ...interface{})
Error calls OutputErr to print to the standard logger's error channel. Arguments are handled in the manner of fmt.Print.
func Errorf ¶
func Errorf(format string, v ...interface{})
Errorf calls OutputErr to print to the standard logger's error channel. Arguments are handled in the manner of fmt.Printf.
func Errorln ¶
func Errorln(v ...interface{})
Errorln calls OutputErr to print to the standard logger's error channel. Arguments are handled in the manner of fmt.Println.
func Fatal ¶
func Fatal(v ...interface{})
Fatal is equivalent to Print() followed by a call to os.Exit(1).
func Fatalf ¶
func Fatalf(format string, v ...interface{})
Fatalf is equivalent to Printf() followed by a call to os.Exit(1).
func Fatalln ¶
func Fatalln(v ...interface{})
Fatalln is equivalent to Println() followed by a call to os.Exit(1).
func FormatTimestamp ¶
FormatTimestamp returns a formatted timestamp for the standard logger.
func Panic ¶
func Panic(v ...interface{})
Panic is equivalent to Print() followed by a call to panic().
func Panicf ¶
func Panicf(format string, v ...interface{})
Panicf is equivalent to Printf() followed by a call to panic().
func Panicln ¶
func Panicln(v ...interface{})
Panicln is equivalent to Println() followed by a call to panic().
func Print ¶
func Print(v ...interface{})
Print calls Output to print to the standard logger. Arguments are handled in the manner of fmt.Print.
func PrintAuthf ¶
func PrintAuthf(username string, req *http.Request, status AuthStatus, format string, a ...interface{})
PrintAuthf writes authentication details to the standard logger. Arguments are handled in the manner of fmt.Printf.
func PrintReq ¶
func PrintReq(username, upstream string, req *http.Request, url url.URL, ts time.Time, status int, size int)
PrintReq writes request details to the standard logger.
func Printf ¶
func Printf(format string, v ...interface{})
Printf calls Output to print to the standard logger. Arguments are handled in the manner of fmt.Printf.
func Println ¶
func Println(v ...interface{})
Println calls Output to print to the standard logger. Arguments are handled in the manner of fmt.Println.
func SetAuthEnabled ¶
func SetAuthEnabled(e bool)
SetAuthEnabled enables or disables auth logging for the standard logger.
func SetAuthTemplate ¶
func SetAuthTemplate(t string)
SetAuthTemplate sets the template for auth logging for the standard logger.
func SetErrOutput ¶
SetErrOutput sets the output destination for the standard logger's error channel.
func SetErrToInfo ¶
func SetErrToInfo(e bool)
SetErrToInfo enables or disables error logging to output writer instead of error writer.
func SetExcludePaths ¶
func SetExcludePaths(s []string)
SetExcludePaths sets the path to exclude from logging, eg: health checks
func SetGetClientFunc ¶
func SetGetClientFunc(f GetClientFunc)
SetGetClientFunc sets the function which determines the apparent IP address set by a reverse proxy for the standard logger.
func SetReqEnabled ¶
func SetReqEnabled(e bool)
SetReqEnabled enables or disables request logging for the standard logger.
func SetReqTemplate ¶
func SetReqTemplate(t string)
SetReqTemplate sets the template for request logging for the standard logger.
func SetStandardEnabled ¶
func SetStandardEnabled(e bool)
SetStandardEnabled enables or disables standard logging for the standard logger.
func SetStandardTemplate ¶
func SetStandardTemplate(t string)
SetStandardTemplate sets the template for standard logging for the standard logger.
Types ¶
type AuthStatus ¶
type AuthStatus string
AuthStatus defines the different types of auth logging that occur
type GetClientFunc ¶
Returns the apparent "real client IP" as a string.
type Logger ¶
type Logger struct {
// contains filtered or unexported fields
}
A Logger represents an active logging object that generates lines of output to an io.Writer passed through a formatter. Each logging operation makes a single call to the Writer's Write method. A Logger can be used simultaneously from multiple goroutines; it guarantees to serialize access to the Writer.
func (*Logger) FormatTimestamp ¶
FormatTimestamp returns a formatted timestamp.
func (*Logger) GetFileLineString ¶
GetFileLineString will find the caller file and line number taking in to account the calldepth to iterate up the stack to find the non-logging call location.
func (*Logger) Output ¶
Output a standard log template with a simple message to default output channel. Write a final newline at the end of every message.
func (*Logger) PrintAuthf ¶
func (l *Logger) PrintAuthf(username string, req *http.Request, status AuthStatus, format string, a ...interface{})
PrintAuthf writes auth info to the logger. Requires an http.Request to log request details. Remaining arguments are handled in the manner of fmt.Sprintf. Writes a final newline to the end of every message.
func (*Logger) PrintReq ¶
func (l *Logger) PrintReq(username, upstream string, req *http.Request, url url.URL, ts time.Time, status int, size int)
PrintReq writes request details to the Logger using the http.Request, url, and timestamp of the request. Writes a final newline to the end of every message.
func (*Logger) SetAuthEnabled ¶
SetAuthEnabled enables or disables auth logging.
func (*Logger) SetAuthTemplate ¶
SetAuthTemplate sets the template for auth logging.
func (*Logger) SetErrToInfo ¶
SetErrToInfo enables or disables error logging to error writer instead of the default.
func (*Logger) SetExcludePaths ¶
SetExcludePaths sets the paths to exclude from logging.
func (*Logger) SetGetClientFunc ¶
func (l *Logger) SetGetClientFunc(f GetClientFunc)
SetGetClientFunc sets the function which determines the apparent "real client IP".
func (*Logger) SetReqEnabled ¶
SetReqEnabled enabled or disables request logging.
func (*Logger) SetReqTemplate ¶
SetReqTemplate sets the template for request logging.
func (*Logger) SetStandardEnabled ¶
SetStandardEnabled enables or disables standard logging.
func (*Logger) SetStandardTemplate ¶
SetStandardTemplate sets the template for standard logging.