dirty but its tailing.. need to regex out the RGB stuff (@54;>65=85 38?5@A5B8:)

This commit is contained in:
2019-12-19 04:42:11 +00:00
parent 9f159ebde5
commit fc74167a06
4 changed files with 57 additions and 4 deletions
+47 -1
View File
@@ -5,15 +5,31 @@ import (
"github.com/hpcloud/tail"
"github.com/radovskyb/watcher"
"log"
"os"
"strings"
"time"
)
func Tail(file string) {
// https://godoc.org/github.com/hpcloud/tail#Config
//t, err := follower.New(file, follower.Config{
// Whence: io.SeekEnd,
// //Offset: 0,
// Reopen: true,
//})
//t, err := scroller.NewScroller(file)
stats, err := os.Stat(file)
if err != nil {
fmt.Println(err)
}
size := stats.Size()
t, err := tail.TailFile(
file,
tail.Config{
Follow: true,
Location: &tail.SeekInfo{Offset: size, Whence: 0},
})
if err != nil {
fmt.Println(err)
@@ -26,16 +42,46 @@ func Tail(file string) {
//currentLine := 0
for line := range t.Lines {
BasicLineParse(line.Text)
//fmt.Printf("%v/%v", currentLine, totalLines)
//currentLine ++
//if currentLine > totalLines {
fmt.Printf("##%v##%v##\n", line.Time, line.Text)
// fmt.Printf("##%v##%v##\n", line.Time, line.Text)
//}
}
}
// clean the eve log format a little
func BasicLineParse(input string) {
//// Make a Regex to say we only want letters and numbers
//reg, err := regexp.Compile("[^a-zA-Z0-9 ./+-_=]+")
//if err != nil {
// log.Fatal(err)
//}
//processedString := reg.ReplaceAllString(input, "")
splitBySpaces := strings.Split(input, " ")
//runedString := []rune(splitBySpaces)
// count how many characters.. minus the 20 at the end
// EG:
// "Rookie Help_20191218_161504.txt"
// becomes: "Rookie Help"
//chars := len(c) - 20
//myShortString := string(c[0:chars])
//fmt.Printf("#%v# |%v| @%v@\n\n",a[1], a[2], a[3:])
fmt.Printf("%s\n", splitBySpaces[4:])
//return "asdasd"
}
// sends newly created files for tail'ing
// WIP