Documentation ¶
Overview ¶
Package xlog is an xlogfile parsing and manipulation library.
Index ¶
- Variables
- func FindSeparator(s string) int
- func IsKeyHidden(key string) bool
- func IsPotentialXlogLine(line string) bool
- func QuoteValue(value string) string
- func UnquoteValue(value string) string
- type ParseError
- type Reader
- func (x *Reader) BackToLastCompleteLine() error
- func (x *Reader) Close() error
- func (x *Reader) Next() (Xlog, error)
- func (x *Reader) ReadAll() ([]Xlog, error)
- func (x *Reader) ReadCompleteLine() (string, error)
- func (x *Reader) SeekNext(offset int64) error
- func (x *Reader) SeekOffset(offset int64) error
- func (x *Reader) String() string
- type Xlog
Constants ¶
This section is empty.
Variables ¶
var ErrNoFile = errors.New("xlog file not found")
ErrNoFile means an attempt was made to read a missing xlog
Functions ¶
func FindSeparator ¶
FindSeparator finds the first non-escaped occurrence of the xlog separator ':' in the string and returns the byte offset of that occurrence, or -1 if the separator is not present in the string.
func IsKeyHidden ¶
IsKeyHidden checks if key is a *hidden* xlog fieldname
func IsPotentialXlogLine ¶
IsPotentialXlogLine returns true if line looks like it might be a valid Xlog line. This is a convenient shortcut to discard trivial invalid lines such as blank lines and lines starting with colons.
It is the caller's responsibility to strip any extraneous leading and trailing space, including trailing newlines.
func QuoteValue ¶
QuoteValue quotes an Xlog value field by escaping embedded ":" as "::".
func UnquoteValue ¶
UnquoteValue unquotes an Xlog value, replacing "::" with ":".
Types ¶
type ParseError ¶
A ParseError is an error in parsing an xlog line.
func (*ParseError) ErrRuneIndex ¶
func (e *ParseError) ErrRuneIndex() int
ErrRuneIndex gets the rune index of the parse error in the xlog Line.
func (*ParseError) Error ¶
func (e *ParseError) Error() string
type Reader ¶
type Reader struct { // SourceKey is a unique identifier for the server this logfile is from SourceKey string Path string Filename string File *os.File Offset int64 Reader *bufio.Reader }
A Reader reads xlog entries from a logfile.
func NewReader ¶
NewReader creates a new Reader for the given absolute path, and dbFilename. The dbFilename will be saved as the filename in the database.
func (*Reader) BackToLastCompleteLine ¶
BackToLastCompleteLine rewinds the XlogReader to the end of the last complete line read, or the last place explicitly Seek()ed to; does nothing if nothing read yet.
func (*Reader) Next ¶
Next reads the next xlog entry from the logfile, skipping blank lines. When EOF is reached, returns nil with no error.
func (*Reader) ReadAll ¶
ReadAll reads all available Xlog lines from the source; use only for testing.
func (*Reader) ReadCompleteLine ¶
ReadCompleteLine reads a complete line from the Xlog reader, returning an empty string if it can't read a full \n-terminated line. The line returned is always empty or \n-terminated.
func (*Reader) SeekNext ¶
SeekNext seeks to the given offset, then reads and discards one complete line. This is convenient if you have the offset of the last processed line and want to resume reading on the next line.
func (*Reader) SeekOffset ¶
SeekOffset seeks to the given offset from the start of the file.