Documentation ¶
Overview ¶
Package hunkee provides interface to parse log entries like you do in sqlx.
Index ¶
- Variables
- type Parser
- func (p *Parser) ParseLine(line string, to interface{}) error
- func (p *Parser) SetCommentPrefix(pref string)
- func (p *Parser) SetDebug(val bool)
- func (p *Parser) SetMultiplyTimeLayout(tagToLayouts map[string]string)
- func (p *Parser) SetTimeLayout(tag, timeLayout string)
- func (p *Parser) SetTimeLocation(tag string, loc *time.Location)
- func (p *Parser) SetTimeOption(tag string, to *TimeOption)
- func (p *Parser) SetTokenSeparator(sep byte)
- func (p *Parser) SetWorkersAmount(amount int)
- func (p *Parser) TimeOption(tag string) *TimeOption
- type TimeOption
Constants ¶
This section is empty.
Variables ¶
var ( ErrSyntax = errors.New("syntax error") ErrOnlyStructs = errors.New("only struct types supported") ErrNotSpecified = errors.New("tag not specified") ErrNotUint = errors.New("corresponded kind is not Uint-like") ErrNotInt = errors.New("corresponded kind is not Int-like") ErrNotFloat = errors.New("corresponded kind is not Float32 or Float64") ErrEmptyLine = errors.New("empty line passed") ErrComaNotSupported = errors.New("coma-separated tag options is not supported") ErrUnexpectedColon = errors.New("unexpected ':' while parsing format string") ErrNotSupportedType = errors.New("corresponded kind is not supported") ErrNilTimeOptions = errors.New("nil time options, time cannot be parsed") )
Functions ¶
This section is empty.
Types ¶
type Parser ¶
type Parser struct {
// contains filtered or unexported fields
}
func (*Parser) ParseLine ¶
ParseLine gets line of input and structure to parse in Returns ErrEmptyLine if passed empty string or string with only \n
func (*Parser) SetCommentPrefix ¶
SetCommentPrefix receives prefix which from will be start commented lines. As soon parser will get string with such prefix, that line will be ignored. Default commentary prefix is '#'.
func (*Parser) SetMultiplyTimeLayout ¶
SetMultiplyTimeLayout receives map of TAG -> LAYOUT and sets up proposed layouts for different fields by their tag.
func (*Parser) SetTimeLayout ¶
SetTimeLayout setups provided time layout for time.Time fields in log entry. By default it's corresponded to RFC3339 - "2006-01-02T15:04:05Z07:00"
func (*Parser) SetTimeLocation ¶
SetTimeLocation used to parse time in provided location.
func (*Parser) SetTimeOption ¶
func (p *Parser) SetTimeOption(tag string, to *TimeOption)
SetTimeOption sets provided timeOption to provided tag. Make sure you do it once at start, no andy dynamic behavior
func (*Parser) SetTokenSeparator ¶
SetTokenSeparator receives byte which will be before token and right after it (useful when some fields contains more than one word). E.g. provided line:
'"user" "123" "hunkee is slow"' with the next format line: ':name :id :description' The token separator here is '"'.
func (*Parser) SetWorkersAmount ¶
SetWorkersAmount increases amount of workers from current value (10 by default) up to provided value
func (*Parser) TimeOption ¶
func (p *Parser) TimeOption(tag string) *TimeOption
TimeOption returns corresponded TimeOptions for tag
type TimeOption ¶
func DefaultTimeOptions ¶
func DefaultTimeOptions() *TimeOption