chore: Add simple parsers for journald and tail files
This commit is contained in:
@@ -0,0 +1,31 @@
|
||||
package parser
|
||||
|
||||
import (
|
||||
"bufio"
|
||||
"os/exec"
|
||||
)
|
||||
|
||||
type Parser struct {
|
||||
parser *bufio.Scanner
|
||||
ch chan string
|
||||
cmd *exec.Cmd
|
||||
file *string
|
||||
}
|
||||
|
||||
func (p *Parser) Start() {
|
||||
go func() {
|
||||
for p.parser.Scan() {
|
||||
p.ch <- p.parser.Text()
|
||||
}
|
||||
}()
|
||||
}
|
||||
|
||||
func (p *Parser) Stop() {
|
||||
if p.cmd != nil && p.cmd.Process != nil {
|
||||
p.cmd.Process.Kill()
|
||||
}
|
||||
}
|
||||
|
||||
func (p *Parser) Channel() <-chan string {
|
||||
return p.ch
|
||||
}
|
||||
Reference in New Issue
Block a user