Documentation ¶
Index ¶
- type AutoFile
- type Group
- func (g *Group) FindLast(prefix string) (match string, found bool, err error)
- func (g *Group) Flush() error
- func (g *Group) HeadSizeLimit() int64
- func (g *Group) MaxIndex() int
- func (g *Group) NewReader(index int) (*GroupReader, error)
- func (g *Group) OnStart() error
- func (g *Group) OnStop()
- func (g *Group) ReadGroupInfo() GroupInfo
- func (g *Group) RotateFile()
- func (g *Group) Search(prefix string, cmp SearchFunc) (*GroupReader, bool, error)
- func (g *Group) SetHeadSizeLimit(limit int64)
- func (g *Group) SetTotalSizeLimit(limit int64)
- func (g *Group) TotalSizeLimit() int64
- func (g *Group) WriteLine(line string) error
- type GroupInfo
- type GroupReader
- type SearchFunc
- type SighupWatcher
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AutoFile ¶
Automatically closes and re-opens file for writing. This is useful for using a log file with the logrotate tool.
func OpenAutoFile ¶
type Group ¶
type Group struct { gcmn.BaseService ID string Head *AutoFile // The head AutoFile to write to Dir string // Directory that contains .Head // contains filtered or unexported fields }
func (*Group) FindLast ¶
Searches backwards for the last line in Group with prefix. Scans each file forward until the end to find the last match.
func (*Group) HeadSizeLimit ¶
func (*Group) NewReader ¶
func (g *Group) NewReader(index int) (*GroupReader, error)
NOTE: if error, returns no GroupReader. CONTRACT: Caller must close the returned GroupReader
func (*Group) ReadGroupInfo ¶
Returns info after scanning all files in g.Head's dir
func (*Group) RotateFile ¶
func (g *Group) RotateFile()
func (*Group) Search ¶
func (g *Group) Search(prefix string, cmp SearchFunc) (*GroupReader, bool, error)
Searches for the right file in Group, then returns a GroupReader to start streaming lines. Returns true if an exact match was found, otherwise returns the next greater line that starts with prefix. CONTRACT: Caller must close the returned GroupReader
func (*Group) SetHeadSizeLimit ¶
func (*Group) SetTotalSizeLimit ¶
func (*Group) TotalSizeLimit ¶
type GroupReader ¶
type GroupReader struct { *Group // contains filtered or unexported fields }
func (*GroupReader) Close ¶
func (gr *GroupReader) Close() error
func (*GroupReader) PushLine ¶
func (gr *GroupReader) PushLine(line string)
func (*GroupReader) ReadLine ¶
func (gr *GroupReader) ReadLine() (string, error)
Reads a line (without delimiter) just return io.EOF if no new lines found.
func (*GroupReader) SetIndex ¶
func (gr *GroupReader) SetIndex(index int) error
type SearchFunc ¶
Returns -1 if line comes after, 0 if found, 1 if line comes before.
func MakeSimpleSearchFunc ¶
func MakeSimpleSearchFunc(prefix string, target int) SearchFunc
A simple SearchFunc that assumes that the marker is of form <prefix><number>. For example, if prefix is '#HEIGHT:', the markers of expected to be of the form:
#HEIGHT:1 ... #HEIGHT:2 ...
type SighupWatcher ¶
type SighupWatcher struct {
// contains filtered or unexported fields
}
Watchces for SIGHUP events and notifies registered AutoFiles