Documentation ¶
Index ¶
- Constants
- Variables
- func BytesReceivedGetter(info types.RequestInfo) string
- func BytesSentGetter(info types.RequestInfo) string
- func CloseAll() (err error)
- func DisableAllAccessLog()
- func DownstreamLocalAddressGetter(info types.RequestInfo) string
- func DownstreamRemoteAddressGetter(info types.RequestInfo) string
- func DurationGetter(info types.RequestInfo) string
- func GetResponseFlagGetter(info types.RequestInfo) string
- func InitDefaultLogger(output string, level Level) (err error)
- func InitGlobalRoller(roller string) error
- func IsLogRollerSubdirective(subdir string) bool
- func NewAccessLog(output string, filter types.AccessLogFilter, format string) (types.AccessLog, error)
- func NewAccessLogFormatter(format string) types.AccessLogFormatter
- func ProtocolGetter(info types.RequestInfo) string
- func ReceivedDurationGetter(info types.RequestInfo) string
- func Reopen() (err error)
- func RequestFinishedDurationGetter(info types.RequestInfo) string
- func ResponseCodeGetter(info types.RequestInfo) string
- func ResponseReceivedDurationGetter(info types.RequestInfo) string
- func StartTimeGetter(info types.RequestInfo) string
- func ToggleLogger(p string, disable bool) bool
- func UpdateErrorLoggerLevel(p string, level Level) bool
- func UpstreamHostSelectedGetter(info types.RequestInfo) string
- func UpstreamLocalAddressGetter(info types.RequestInfo) string
- type CreateErrorLoggerFunc
- type ErrorLogger
- type ErrorLoggerManager
- type Level
- type Logger
- func (l *Logger) Close() error
- func (l *Logger) Fatal(args ...interface{})
- func (l *Logger) Fatalf(format string, args ...interface{})
- func (l *Logger) Fatalln(args ...interface{})
- func (l *Logger) Print(buf types.IoBuffer, discard bool) error
- func (l *Logger) Printf(format string, args ...interface{})
- func (l *Logger) Println(args ...interface{})
- func (l *Logger) Reopen() error
- func (l *Logger) Toggle(disable bool)
- func (l *Logger) Write(p []byte) (n int, err error)
- type ProxyLogger
- type Roller
Constants ¶
const ( InfoPre string = "[INFO]" DebugPre string = "[DEBUG]" WarnPre string = "[WARN]" ErrorPre string = "[ERROR]" FatalPre string = "[FATAL]" TracePre string = "[TRACE]" )
const AccessLogLen = 1 << 8
Variables ¶
var ( RequestInfoFuncMap map[string]func(info types.RequestInfo) string DefaultDisableAccessLog bool )
RequestInfoFuncMap is a map which key is the format-key, value is the func to get corresponding string value
var ( DefaultLogger ErrorLogger StartLogger ErrorLogger Proxy ProxyLogger ErrNoLoggerFound = errors.New("no logger found in logger manager") )
var ( // error ErrReopenUnsupported = errors.New("reopen unsupported") )
Functions ¶
func BytesReceivedGetter ¶
func BytesReceivedGetter(info types.RequestInfo) string
BytesReceivedGetter get bytes received
func BytesSentGetter ¶
func BytesSentGetter(info types.RequestInfo) string
BytesSentGetter get bytes sent
func DisableAllAccessLog ¶
func DisableAllAccessLog()
func DownstreamLocalAddressGetter ¶
func DownstreamLocalAddressGetter(info types.RequestInfo) string
DownstreamLocalAddressGetter get downstream's local address
func DownstreamRemoteAddressGetter ¶
func DownstreamRemoteAddressGetter(info types.RequestInfo) string
DownstreamRemoteAddressGetter get upstream's remote address
func DurationGetter ¶
func DurationGetter(info types.RequestInfo) string
DurationGetter get duration since request's starting time
func GetResponseFlagGetter ¶
func GetResponseFlagGetter(info types.RequestInfo) string
GetResponseFlagGetter get request's response flag
func InitDefaultLogger ¶
func IsLogRollerSubdirective ¶
IsLogRollerSubdirective is true if the subdirective is for the log roller.
func NewAccessLog ¶
func NewAccessLog(output string, filter types.AccessLogFilter, format string) (types.AccessLog, error)
NewAccessLog
func NewAccessLogFormatter ¶
func NewAccessLogFormatter(format string) types.AccessLogFormatter
NewAccessLogFormatter
func ProtocolGetter ¶
func ProtocolGetter(info types.RequestInfo) string
get request's protocol type
func ReceivedDurationGetter ¶
func ReceivedDurationGetter(info types.RequestInfo) string
ReceivedDurationGetter get duration between request arriving and request resend to upstream
func RequestFinishedDurationGetter ¶
func RequestFinishedDurationGetter(info types.RequestInfo) string
RequestFinishedDurationGetter hets duration between request arriving and request finished
func ResponseCodeGetter ¶
func ResponseCodeGetter(info types.RequestInfo) string
ResponseCodeGetter get request's response code
func ResponseReceivedDurationGetter ¶
func ResponseReceivedDurationGetter(info types.RequestInfo) string
ResponseReceivedDurationGetter get duration between request arriving and response sending
func StartTimeGetter ¶
func StartTimeGetter(info types.RequestInfo) string
StartTimeGetter get request's arriving time
func ToggleLogger ¶
ToggleLogger enable/disable the exists logger, include ErrorLogger and Logger
func UpdateErrorLoggerLevel ¶
UpdateErrorLoggerLevel updates the exists ErrorLogger's Level
func UpstreamHostSelectedGetter ¶
func UpstreamHostSelectedGetter(info types.RequestInfo) string
UpstreamHostSelectedGetter get upstream's selected host address
func UpstreamLocalAddressGetter ¶
func UpstreamLocalAddressGetter(info types.RequestInfo) string
UpstreamLocalAddressGetter get upstream's local address
Types ¶
type CreateErrorLoggerFunc ¶
type CreateErrorLoggerFunc func(output string, level Level) (ErrorLogger, error)
CreateErrorLoggerFunc creates a ErrorLogger implementation by output and level
type ErrorLogger ¶
type ErrorLogger interface { Println(args ...interface{}) Printf(format string, args ...interface{}) // Alertf is a wrapper of Errorf Alertf(errkey types.ErrorKey, format string, args ...interface{}) Infof(format string, args ...interface{}) Debugf(format string, args ...interface{}) Warnf(format string, args ...interface{}) Errorf(format string, args ...interface{}) Tracef(format string, args ...interface{}) Fatalf(format string, args ...interface{}) Fatal(args ...interface{}) Fatalln(args ...interface{}) // SetLogLevel updates the log level SetLogLevel(Level) // GetLogLevel returns the logger's level GetLogLevel() Level // Toggle disable/enable the logger Toggle(disable bool) }
ErrorLogger generates lines of output to an io.Writer
func CreateDefaultErrorLogger ¶
func CreateDefaultErrorLogger(output string, level Level) (ErrorLogger, error)
func GetOrCreateDefaultErrorLogger ¶
func GetOrCreateDefaultErrorLogger(p string, level Level) (ErrorLogger, error)
GetOrCreateDefaultErrorLogger used default create function
type ErrorLoggerManager ¶
type ErrorLoggerManager struct {
// contains filtered or unexported fields
}
ErrorLoggerManager manages error log can be updated dynamicly
func GetErrorLoggerManagerInstance ¶
func GetErrorLoggerManagerInstance() *ErrorLoggerManager
Default Export Functions
func (*ErrorLoggerManager) GetOrCreateErrorLogger ¶
func (mng *ErrorLoggerManager) GetOrCreateErrorLogger(p string, level Level, f CreateErrorLoggerFunc) (ErrorLogger, error)
GetOrCreateErrorLogger returns a ErrorLogger based on the output(p). If Logger not exists, and create function is not nil, creates a new logger
func (*ErrorLoggerManager) SetAllErrorLoggerLevel ¶
func (mng *ErrorLoggerManager) SetAllErrorLoggerLevel(level Level)
type Logger ¶
type Logger struct {
// contains filtered or unexported fields
}
Logger is a basic sync logger implement, contains unexported fields The Logger Function contains: Print(buffer types.IoBuffer, discard bool) error Printf(format string, args ...interface{}) Println(args ...interface{}) Fatalf(format string, args ...interface{}) Fatal(args ...interface{}) Fatalln(args ...interface{}) Close() error Reopen() error Toggle(disable bool)
type ProxyLogger ¶
type ProxyLogger interface { // Alertf is a wrapper of Errorf Alertf(ctx context.Context, errkey types.ErrorKey, format string, args ...interface{}) Infof(ctx context.Context, format string, args ...interface{}) Debugf(ctx context.Context, format string, args ...interface{}) Warnf(ctx context.Context, format string, args ...interface{}) Errorf(ctx context.Context, format string, args ...interface{}) Fatalf(ctx context.Context, format string, args ...interface{}) // SetLogLevel updates the log level SetLogLevel(Level) // GetLogLevel returns the logger's level GetLogLevel() Level // Toggle disable/enable the logger Toggle(disable bool) }
ProxyLogger generates lines of output to an io.Writer, works for data flow
func CreateDefaultProxyLogger ¶
func CreateDefaultProxyLogger(output string, level Level) (ProxyLogger, error)
type Roller ¶
type Roller struct { Filename string MaxSize int MaxAge int MaxBackups int Compress bool LocalTime bool MaxTime int64 }
roller implements a type that provides a rolling logger.
func ParseRoller ¶
ParseRoller parses roller contents out of c.
func (Roller) GetLogWriter ¶
GetLogWriter returns an io.Writer that writes to a rolling logger. This should be called only from the main goroutine (like during server setup) because this method is not thread-safe; it is careful to create only one log writer per log file, even if the log file is shared by different sites or middlewares. This ensures that rolling is synchronized, since a process (or multiple processes) should not create more than one roller on the same file at the same time. See issue #1363.