Documentation
¶
Index ¶
- Constants
- type Entry
- func (e *Entry) Field(key string) ([]string, error)
- func (e *Entry) HeadersField(key string) (http.Header, error)
- func (e *Entry) IntField(key string) (int, error)
- func (e *Entry) NamedField(key, name string) (string, error)
- func (e *Entry) NamedFieldParts(key, name string) ([]string, error)
- func (e *Entry) Timestamp(name string) (*Timestamp, error)
- func (e *Entry) TryField(key string) string
- func (e *Entry) URLField(key string) (*url.URL, error)
- type Fields
- type Timestamp
Constants ¶
const ( Request = "Request" BeReq = "BeReq" )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Entry ¶
Entry holds a single log entry. An entry consists mostly of a collection of log fields.
func Parse ¶
Parse will attempt to produce a single Entry from the log, which it reads using the given scanner.
The process is fairly efficient, as the individual fields (e.g. time-stamps) aren't converted to any special representation. Instead, the parsed entry is kept mostly in its textual form. Only basic processing, such as splitting lines into fields with a key and a value, are performed. The Entry struct provides various convenience methods which perform the subsequent parsing.
func (*Entry) Field ¶
Field returns a fields of the log field with the given key. For example, in "- Foo: bar", "Foo" is the key of the field and "bar" is one of the values returned.
func (*Entry) HeadersField ¶
Headers returns the values of the field with the given key parsed as a list of HTTP headers if possible. Each value of the field has to be a non-empty header name immediately followed by a colon, followed by the optional value of the header. Headers can appear multiple times.
func (*Entry) IntField ¶
IntField returns a field with the given key, converted into an integer if possible.
func (*Entry) NamedField ¶
NamedField returns a structured field with the given key, whose name component is the given name, if it exists. Names are compared case-insensitive to accommodate for HTTP headers.
A structured field is any field whose value is made of an additional name and value components, for example "- BerespHeader: X-Header: foo", where "BerespHeader" is the key, "X-Header" is the name and "foo" is the value returned.
func (*Entry) NamedFieldParts ¶
NamedFieldParts returns the same value as a corresponding NamedFields call, except that the string value is split by whitespace using strings.Fields.
func (*Entry) Timestamp ¶
Timestamp parses and returns a Timestamp with the given name, if the log entry contains such a timestamp.
type Fields ¶
Fields are a collection of log fields. A single log field consists of a key and a list of values which appeared with this key. Consider this fragment of varnishlog output:
- Foo Bar Baz - Foo Foobar - Bar
There are two fields, "Foo" with values "Bar Baz" and "Foobar" and the field "Bar" with an empty string as a sole value.