Documentation
¶
Index ¶
- func GetAlias(inputPaths []string, c *ListFilesConfig, virtualPath string) string
- type FileHandle
- func (r *FileHandle) Close() error
- func (r *FileHandle) FillBuffer() error
- func (r *FileHandle) GetBytesRead() int64
- func (r *FileHandle) GetFileSize() int64
- func (r *FileHandle) IsDone() bool
- func (r *FileHandle) SkipLine() (bytesCount int, eolLength int, err error)
- func (r *FileHandle) WriteLine(m *metrics.MergeMetrics, writer *bufio.Writer) error
- type ListFilesConfig
- type Matcher
- type OsFile
- type VirtualFile
- type WritableFile
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type FileHandle ¶
type FileHandle struct {
File VirtualFile
Alias []byte
AliasForBlock []byte
AliasForLine []byte
Size int64 // Size of the file in bytes
BytesRead int64 // Number of bytes read from the file
Done bool // Whether the file has been fully read
Buffer *container.RingBuffer // Buffer for reading the file
LineTimestampParsed bool // Whether the timestamp for the current line has been parsed
LineTimestamp logtime.Timestamp // The timestamp for the current line
LineTimestampStart int // Byte offset where the timestamp section starts (including leading delimiters)
LineTimestampEnd int // Byte offset where the timestamp section ends (including trailing delimiters)
LineLevel byte // Detected log level for the current line (loglevel.Level)
LineLevelStart int // Byte offset where the level token starts
LineLevelEnd int // Byte offset where the level token ends
BlockTimestamp logtime.Timestamp // The timestamp for the current block, i.e. the last non-zero timestamp
Metrics *metrics.MetricsTree
MergeMetrics *metrics.MergeMetrics
// contains filtered or unexported fields
}
func ListFiles ¶
func ListFiles(inputPaths []string, c *ListFilesConfig, m *metrics.ListFilesMetrics, totalBufferSize int, minBufferSizePerFile int, logFile *WritableFile) (files []*FileHandle, err error)
ListFiles discovers files from inputPaths (files or directories), applies ignore patterns, transparently opens archives, and returns a FileHandle per discovered file.
func NewFileHandle ¶
func NewFileHandle(file VirtualFile, alias string, bufferSize int) (fh *FileHandle, err error)
NewFileHandle creates a FileHandle wrapping the given VirtualFile with its own read buffer and per-file metrics.
func (*FileHandle) Close ¶
func (r *FileHandle) Close() error
Close closes the underlying VirtualFile.
func (*FileHandle) FillBuffer ¶
func (r *FileHandle) FillBuffer() error
FillBuffer reads data from the underlying file into the ring buffer.
func (*FileHandle) GetBytesRead ¶
func (r *FileHandle) GetBytesRead() int64
func (*FileHandle) GetFileSize ¶
func (r *FileHandle) GetFileSize() int64
func (*FileHandle) IsDone ¶
func (r *FileHandle) IsDone() bool
func (*FileHandle) SkipLine ¶
func (r *FileHandle) SkipLine() (bytesCount int, eolLength int, err error)
SkipLine advances past the current line in the buffer without writing it, returning the number of bytes skipped and the EOL length.
func (*FileHandle) WriteLine ¶
func (r *FileHandle) WriteLine(m *metrics.MergeMetrics, writer *bufio.Writer) error
WriteLine writes the current line from the buffer to the writer, ensuring it ends with a newline. Updates byte and line-length metrics.
type ListFilesConfig ¶
type Matcher ¶
type Matcher struct {
// contains filtered or unexported fields
}
func NewMatcher ¶
NewMatcher creates a Matcher from gitignore-style glob patterns. Blank lines and lines starting with # are skipped. Patterns prefixed with ! are negations. A backslash before # or ! escapes the special meaning. Trailing spaces are ignored unless escaped with backslash (\ ).
func (*Matcher) ShouldInclude ¶
ShouldInclude returns whether filePath passes the filter rules. Rules are evaluated in order; the last matching rule wins. Default is include.
type VirtualFile ¶
type VirtualFile interface {
io.ReadCloser
Name() string
Size() int64
}
VirtualFile abstracts a readable file, supporting transparent decompression.
type WritableFile ¶
func (*WritableFile) Close ¶
func (f *WritableFile) Close() error
func (*WritableFile) Initialize ¶
func (f *WritableFile) Initialize() error
Initialize creates the file at Path (and its parent directories). If Path is empty, the existing File handle (e.g. os.Stdout) is left unchanged.
func (*WritableFile) MarshalYAML ¶
func (f *WritableFile) MarshalYAML() (interface{}, error)
func (*WritableFile) UnmarshalYAML ¶
func (f *WritableFile) UnmarshalYAML(value *yaml.Node) error