Documentation
¶
Index ¶
- Variables
- type Filter
- type FilterFunc
- type Level
- func (i Level) Int() int
- func (i Level) IsValid() bool
- func (i Level) MarshalJSON() ([]byte, error)
- func (i Level) MarshalText() (text []byte, err error)
- func (i Level) Ordinal() int
- func (v *Level) Parse(s string) error
- func (i *Level) Scan(value interface{}) (err error)
- func (i Level) String() string
- func (i Level) Tag() string
- func (i *Level) UnmarshalJSON(text []byte) error
- func (i *Level) UnmarshalText(text []byte) error
- func (i Level) Value() (driver.Value, error)
- type LogContent
- type LogItem
- type VariableFilter
Constants ¶
This section is empty.
Variables ¶
var AllLevelEnums = enum.IntEnums{ Off, Discrete, Summary, WithHeaders, WithHeadersAndBodies, }
AllLevelEnums lists all 5 values in order.
var AllLevels = []Level{ Off, Discrete, Summary, WithHeaders, WithHeadersAndBodies, }
AllLevels lists all 5 values in order.
var Now = func() time.Time { return time.Now().UTC() }
Now provides the current time. It can be stubbed for testing.
Functions ¶
This section is empty.
Types ¶
type Filter ¶ added in v0.3.0
A Filter determines the logging level, possibly based on each request.
type FilterFunc ¶ added in v0.3.0
FilterFunc adapts a function to be a Filter.
func FixedLevel ¶ added in v0.3.0
func FixedLevel(level Level) FilterFunc
FixedLevel is a FilterFunc that always return a specified Level.
type Level ¶
type Level int
Level allows control of the predicate of detail in log messages.
const ( // Off turns logging off. Off Level = iota // Discrete log messages contain only a summary of the request and response. // No query parameters are printed in order to hide potential personal information. Discrete // Summary log messages contain only a summary of the request and response, // including the full target URL. Summary // WithHeaders log messages contain a summary and the request/response headers WithHeaders // WithHeadersAndBodies log messages contain a summary and the request/response headers and bodies // Textual bodies are included in the log; for binary content, the size is shown instead. WithHeadersAndBodies )
func AsLevel ¶ added in v0.9.2
AsLevel parses a string to find the corresponding Level, accepting either one of the string values or a number. The input representation is determined by levelMarshalTextRep. It wraps Parse. The input case does not matter.
func LevelOf ¶ added in v0.9.2
LevelOf returns a Level based on an ordinal number. This is the inverse of Ordinal. If the ordinal is out of range, an invalid Level is returned.
func (Level) Int ¶ added in v0.9.2
Int returns the int value, which is not necessarily the same as the ordinal. It serves to facilitate polymorphism (see enum.IntEnum).
func (Level) IsValid ¶ added in v0.9.2
IsValid determines whether a Level is one of the defined constants.
func (Level) MarshalJSON ¶ added in v0.9.2
MarshalJSON converts values to bytes suitable for transmission via JSON. The representation is chosen according to levelMarshalTextRep.
func (Level) MarshalText ¶ added in v0.9.2
MarshalText converts values to a form suitable for transmission via JSON, XML etc. The representation is chosen according to levelMarshalTextRep.
func (*Level) Parse ¶ added in v0.9.2
Parse parses a string to find the corresponding Level, accepting one of the string values or a number. The input representation is determined by levelMarshalTextRep. It is used by AsLevel. The input case does not matter.
Usage Example
v := new(Level) err := v.Parse(s) ... etc
func (*Level) Scan ¶ added in v0.9.2
Scan parses some value, which can be a number, a string or []byte. It implements sql.Scanner, https://golang.org/pkg/database/sql/#Scanner
func (Level) String ¶ added in v0.0.7
String returns the literal string representation of a Level, which is the same as the const identifier.
func (Level) Tag ¶ added in v0.0.8
Tag returns the string representation of a Level. This is an alias for String.
func (*Level) UnmarshalJSON ¶ added in v0.9.2
UnmarshalJSON converts transmitted JSON values to ordinary values. It allows both ordinals and strings to represent the values.
func (*Level) UnmarshalText ¶ added in v0.9.2
UnmarshalText converts transmitted values to ordinary values.
type LogItem ¶
type LogItem struct {
Method string
URL *url.URL
StatusCode int
Request LogContent
Response LogContent
Err error
Start time.Time
Duration time.Duration
Level Level
}
LogItem records information about one HTTP round-trip.
type VariableFilter ¶ added in v0.3.0
type VariableFilter struct {
// contains filtered or unexported fields
}
VariableFilter is a Filter that is controlled by a predicate. This predicate can be altered by any goroutine at any time.
func NewVariableFilter ¶ added in v0.3.0
func NewVariableFilter(initial Level) *VariableFilter
NewVariableFilter is a Filter that initially has a fixed level. However, its predicate can be changed later.
func NewVariablePredicate ¶ added in v0.3.0
func NewVariablePredicate(initial FilterFunc) *VariableFilter
NewVariablePredicate is a Filter with a predicate that can be changed later.
func (*VariableFilter) Level ¶ added in v0.3.0
func (vf *VariableFilter) Level(req *http.Request) Level
func (*VariableFilter) SetLevel ¶ added in v0.3.0
func (vf *VariableFilter) SetLevel(newLevel FilterFunc)
SetLevel allows the predicate to be changed. This can be called from any goroutine.