-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.go
More file actions
52 lines (45 loc) · 1021 Bytes
/
main.go
File metadata and controls
52 lines (45 loc) · 1021 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
package main
import (
"fmt"
"log"
"os"
"hyperbyte-logs/internal/tlog"
"hyperbyte-logs/internal/ui"
)
// Implementation moved to internal packages `tlog` and `ui`.
var defaultLogPaths = []string{
"/var/log/syslog",
"/var/log/messages",
"/var/log/kern.log",
"/var/log/dmesg",
"/var/log/auth.log",
"/var/log/system.log",
"/var/log/daemon.log",
}
func main() {
files := os.Args[1:]
if len(files) == 0 {
fmt.Println("No files specified, using default system logs...")
for _, f := range defaultLogPaths {
if _, err := os.Stat(f); err == nil {
files = append(files, f)
}
}
if len(files) == 0 {
fmt.Println("No readable default log files found.")
os.Exit(1)
}
}
tailers := make([]*tlog.Tailer, len(files))
for i, file := range files {
t, err := tlog.NewTailer(file)
if err != nil {
log.Fatalf("Failed to tail %s: %v", file, err)
}
tailers[i] = t
}
application := ui.NewAppUI(tailers)
if err := application.Run(); err != nil {
log.Fatalf("UI error: %v", err)
}
}