Skip to content

Commit 7253ae9

Browse files
authored
Merge pull request #19 from SOORAJTS2001/feat/installation
Feat: change scroll behaviour of UI, and sql driver to pure go version
2 parents 9f5b2b5 + 3fd62f5 commit 7253ae9

15 files changed

Lines changed: 154 additions & 106 deletions

File tree

cli/api/backend.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ import (
1616
)
1717

1818
func BatchUpload(db_con *sql.DB,batch []models.LogEntry,userId string, sessionId string, tag string, retries int, backendDisabled *bool) error {
19-
fmt.Println("Trying to batch upload")
2019
if len(batch) == 0 {
2120
return nil
2221
}

cli/db/db.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import (
55
"cli/models"
66
"database/sql"
77
"fmt"
8-
_ "github.com/mattn/go-sqlite3"
8+
_ "modernc.org/sqlite"
99
"os"
1010
"path/filepath"
1111
)
@@ -16,7 +16,7 @@ func dbPath() string {
1616

1717
func InitDB() *sql.DB {
1818
var err error
19-
db, err := sql.Open("sqlite3", dbPath())
19+
db, err := sql.Open("sqlite", dbPath())
2020
if err != nil {
2121
fmt.Printf("failed to open sqlite: %v\n", err)
2222
os.Exit(1)

cli/executor/main.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,11 @@ func Executor(wg *sync.WaitGroup,args []string,sessionId string,filename string)
3434
end := fmt.Sprintf("</%s>",sessionId)
3535
for scanner.Scan() {
3636
line := scanner.Text()
37+
// this is the live logs from the programme, don't comment it
38+
fmt.Println(line)
3739

3840
line = start + line + end + "\n"
3941

40-
fmt.Println(line)
4142
// Write live to file
4243
lineBytes := []byte(line)
4344
_, err = logFile.Write(lineBytes)

cli/go.mod

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,18 @@ go 1.24.2
55
require (
66
github.com/creack/pty v1.1.24
77
github.com/fsnotify/fsnotify v1.9.0
8+
modernc.org/sqlite v1.44.3
89
)
910

1011
require (
11-
github.com/mattn/go-sqlite3 v1.14.32 // indirect
12-
golang.org/x/sys v0.13.0 // indirect
12+
github.com/dustin/go-humanize v1.0.1 // indirect
13+
github.com/google/uuid v1.6.0 // indirect
14+
github.com/mattn/go-isatty v0.0.20 // indirect
15+
github.com/ncruces/go-strftime v1.0.0 // indirect
16+
github.com/remyoudompheng/bigfft v0.0.0-20230129092748-24d4a6f8daec // indirect
17+
golang.org/x/exp v0.0.0-20251023183803-a4bb9ffd2546 // indirect
18+
golang.org/x/sys v0.37.0 // indirect
19+
modernc.org/libc v1.67.6 // indirect
20+
modernc.org/mathutil v1.7.1 // indirect
21+
modernc.org/memory v1.11.0 // indirect
1322
)

cli/go.sum

Lines changed: 53 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,57 @@
11
github.com/creack/pty v1.1.24 h1:bJrF4RRfyJnbTJqzRLHzcGaZK1NeM5kTC9jGgovnR1s=
22
github.com/creack/pty v1.1.24/go.mod h1:08sCNb52WyoAwi2QDyzUCTgcvVFhUzewun7wtTfvcwE=
3+
github.com/dustin/go-humanize v1.0.1 h1:GzkhY7T5VNhEkwH0PVJgjz+fX1rhBrR7pRT3mDkpeCY=
4+
github.com/dustin/go-humanize v1.0.1/go.mod h1:Mu1zIs6XwVuF/gI1OepvI0qD18qycQx+mFykh5fBlto=
35
github.com/fsnotify/fsnotify v1.9.0 h1:2Ml+OJNzbYCTzsxtv8vKSFD9PbJjmhYF14k/jKC7S9k=
46
github.com/fsnotify/fsnotify v1.9.0/go.mod h1:8jBTzvmWwFyi3Pb8djgCCO5IBqzKJ/Jwo8TRcHyHii0=
5-
github.com/mattn/go-sqlite3 v1.14.32 h1:JD12Ag3oLy1zQA+BNn74xRgaBbdhbNIDYvQUEuuErjs=
6-
github.com/mattn/go-sqlite3 v1.14.32/go.mod h1:Uh1q+B4BYcTPb+yiD3kU8Ct7aC0hY9fxUwlHK0RXw+Y=
7-
golang.org/x/sys v0.13.0 h1:Af8nKPmuFypiUBjVoU9V20FiaFXOcuZI21p0ycVYYGE=
8-
golang.org/x/sys v0.13.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
7+
github.com/google/pprof v0.0.0-20250317173921-a4b03ec1a45e h1:ijClszYn+mADRFY17kjQEVQ1XRhq2/JR1M3sGqeJoxs=
8+
github.com/google/pprof v0.0.0-20250317173921-a4b03ec1a45e/go.mod h1:boTsfXsheKC2y+lKOCMpSfarhxDeIzfZG1jqGcPl3cA=
9+
github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0=
10+
github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
11+
github.com/hashicorp/golang-lru/v2 v2.0.7 h1:a+bsQ5rvGLjzHuww6tVxozPZFVghXaHOwFs4luLUK2k=
12+
github.com/hashicorp/golang-lru/v2 v2.0.7/go.mod h1:QeFd9opnmA6QUJc5vARoKUSoFhyfM2/ZepoAG6RGpeM=
13+
github.com/mattn/go-isatty v0.0.20 h1:xfD0iDuEKnDkl03q4limB+vH+GxLEtL/jb4xVJSWWEY=
14+
github.com/mattn/go-isatty v0.0.20/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y=
15+
github.com/ncruces/go-strftime v1.0.0 h1:HMFp8mLCTPp341M/ZnA4qaf7ZlsbTc+miZjCLOFAw7w=
16+
github.com/ncruces/go-strftime v1.0.0/go.mod h1:Fwc5htZGVVkseilnfgOVb9mKy6w1naJmn9CehxcKcls=
17+
github.com/remyoudompheng/bigfft v0.0.0-20230129092748-24d4a6f8daec h1:W09IVJc94icq4NjY3clb7Lk8O1qJ8BdBEF8z0ibU0rE=
18+
github.com/remyoudompheng/bigfft v0.0.0-20230129092748-24d4a6f8daec/go.mod h1:qqbHyh8v60DhA7CoWK5oRCqLrMHRGoxYCSS9EjAz6Eo=
19+
golang.org/x/exp v0.0.0-20251023183803-a4bb9ffd2546 h1:mgKeJMpvi0yx/sU5GsxQ7p6s2wtOnGAHZWCHUM4KGzY=
20+
golang.org/x/exp v0.0.0-20251023183803-a4bb9ffd2546/go.mod h1:j/pmGrbnkbPtQfxEe5D0VQhZC6qKbfKifgD0oM7sR70=
21+
golang.org/x/mod v0.29.0 h1:HV8lRxZC4l2cr3Zq1LvtOsi/ThTgWnUk/y64QSs8GwA=
22+
golang.org/x/mod v0.29.0/go.mod h1:NyhrlYXJ2H4eJiRy/WDBO6HMqZQ6q9nk4JzS3NuCK+w=
23+
golang.org/x/sync v0.17.0 h1:l60nONMj9l5drqw6jlhIELNv9I0A4OFgRsG9k2oT9Ug=
24+
golang.org/x/sync v0.17.0/go.mod h1:9KTHXmSnoGruLpwFjVSX0lNNA75CykiMECbovNTZqGI=
25+
golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
26+
golang.org/x/sys v0.37.0 h1:fdNQudmxPjkdUTPnLn5mdQv7Zwvbvpaxqs831goi9kQ=
27+
golang.org/x/sys v0.37.0/go.mod h1:OgkHotnGiDImocRcuBABYBEXf8A9a87e/uXjp9XT3ks=
28+
golang.org/x/tools v0.38.0 h1:Hx2Xv8hISq8Lm16jvBZ2VQf+RLmbd7wVUsALibYI/IQ=
29+
golang.org/x/tools v0.38.0/go.mod h1:yEsQ/d/YK8cjh0L6rZlY8tgtlKiBNTL14pGDJPJpYQs=
30+
modernc.org/cc/v4 v4.27.1 h1:9W30zRlYrefrDV2JE2O8VDtJ1yPGownxciz5rrbQZis=
31+
modernc.org/cc/v4 v4.27.1/go.mod h1:uVtb5OGqUKpoLWhqwNQo/8LwvoiEBLvZXIQ/SmO6mL0=
32+
modernc.org/ccgo/v4 v4.30.1 h1:4r4U1J6Fhj98NKfSjnPUN7Ze2c6MnAdL0hWw6+LrJpc=
33+
modernc.org/ccgo/v4 v4.30.1/go.mod h1:bIOeI1JL54Utlxn+LwrFyjCx2n2RDiYEaJVSrgdrRfM=
34+
modernc.org/fileutil v1.3.40 h1:ZGMswMNc9JOCrcrakF1HrvmergNLAmxOPjizirpfqBA=
35+
modernc.org/fileutil v1.3.40/go.mod h1:HxmghZSZVAz/LXcMNwZPA/DRrQZEVP9VX0V4LQGQFOc=
36+
modernc.org/gc/v2 v2.6.5 h1:nyqdV8q46KvTpZlsw66kWqwXRHdjIlJOhG6kxiV/9xI=
37+
modernc.org/gc/v2 v2.6.5/go.mod h1:YgIahr1ypgfe7chRuJi2gD7DBQiKSLMPgBQe9oIiito=
38+
modernc.org/gc/v3 v3.1.1 h1:k8T3gkXWY9sEiytKhcgyiZ2L0DTyCQ/nvX+LoCljoRE=
39+
modernc.org/gc/v3 v3.1.1/go.mod h1:HFK/6AGESC7Ex+EZJhJ2Gni6cTaYpSMmU/cT9RmlfYY=
40+
modernc.org/goabi0 v0.2.0 h1:HvEowk7LxcPd0eq6mVOAEMai46V+i7Jrj13t4AzuNks=
41+
modernc.org/goabi0 v0.2.0/go.mod h1:CEFRnnJhKvWT1c1JTI3Avm+tgOWbkOu5oPA8eH8LnMI=
42+
modernc.org/libc v1.67.6 h1:eVOQvpModVLKOdT+LvBPjdQqfrZq+pC39BygcT+E7OI=
43+
modernc.org/libc v1.67.6/go.mod h1:JAhxUVlolfYDErnwiqaLvUqc8nfb2r6S6slAgZOnaiE=
44+
modernc.org/mathutil v1.7.1 h1:GCZVGXdaN8gTqB1Mf/usp1Y/hSqgI2vAGGP4jZMCxOU=
45+
modernc.org/mathutil v1.7.1/go.mod h1:4p5IwJITfppl0G4sUEDtCr4DthTaT47/N3aT6MhfgJg=
46+
modernc.org/memory v1.11.0 h1:o4QC8aMQzmcwCK3t3Ux/ZHmwFPzE6hf2Y5LbkRs+hbI=
47+
modernc.org/memory v1.11.0/go.mod h1:/JP4VbVC+K5sU2wZi9bHoq2MAkCnrt2r98UGeSK7Mjw=
48+
modernc.org/opt v0.1.4 h1:2kNGMRiUjrp4LcaPuLY2PzUfqM/w9N23quVwhKt5Qm8=
49+
modernc.org/opt v0.1.4/go.mod h1:03fq9lsNfvkYSfxrfUhZCWPk1lm4cq4N+Bh//bEtgns=
50+
modernc.org/sortutil v1.2.1 h1:+xyoGf15mM3NMlPDnFqrteY07klSFxLElE2PVuWIJ7w=
51+
modernc.org/sortutil v1.2.1/go.mod h1:7ZI3a3REbai7gzCLcotuw9AC4VZVpYMjDzETGsSMqJE=
52+
modernc.org/sqlite v1.44.3 h1:+39JvV/HWMcYslAwRxHb8067w+2zowvFOUrOWIy9PjY=
53+
modernc.org/sqlite v1.44.3/go.mod h1:CzbrU2lSB1DKUusvwGz7rqEKIq+NUd8GWuBBZDs9/nA=
54+
modernc.org/strutil v1.2.1 h1:UneZBkQA+DX2Rp35KcM69cSsNES9ly8mQWD71HKlOA0=
55+
modernc.org/strutil v1.2.1/go.mod h1:EHkiggD70koQxjVdSBM3JKM7k6L0FbGE5eymy9i3B9A=
56+
modernc.org/token v1.1.0 h1:Xl7Ap9dKaEs5kLoOQeQmPWevfnk/DM5qcLcYlA8ys6Y=
57+
modernc.org/token v1.1.0/go.mod h1:UGzOrNV1mAFSEB63lOFHIpNRUVMvYTc6yu1SMY/XTDM=

cli/main.go

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,6 @@ func main() {
5656
setup.Setup(true)
5757
pollInterval, batchSize, tag,parsed_args := runArgParser()
5858
command,commandArgs = parsed_args[0],parsed_args[1:]
59-
fmt.Println(pollInterval,batchSize,tag)
6059
db.UpsertSessionById(setup.DB_con,utils.NewSession(setup.SessionId,tag,setup.UserId))
6160
wg := &sync.WaitGroup{}
6261
tmpFile := filepath.Join(constants.TmpDir, setup.SessionId+".log")
@@ -68,7 +67,6 @@ func main() {
6867

6968
// --- Start executor in foreground ---
7069
executorArgs := append([]string{command}, commandArgs...)
71-
fmt.Println(executorArgs)
7270
wg.Add(1)
7371
go executor.Executor(wg, executorArgs,setup.SessionId, tmpFile)
7472

@@ -82,12 +80,8 @@ func main() {
8280
os.Exit(1)
8381
}()
8482

85-
// Wait for executor to finish
86-
fmt.Println("Executor finished.")
8783

8884
// Wait for tailer to finish
8985
wg.Wait()
90-
fmt.Println("Tailer finished.")
91-
fmt.Println("Wrapper finished.")
9286
os.Remove(tmpFile)
9387
}

cli/tail/main.go

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ var backendDisabled bool = false
2121

2222
func Tail(wg *sync.WaitGroup,pollInterval time.Duration,batchSize int,tag string, sessionId string,filePath string) {
2323
defer wg.Done()
24-
fmt.Println("Poll:", pollInterval, "Batch:", batchSize)
2524

2625
watcher, err := fsnotify.NewWatcher()
2726
if err != nil {
@@ -33,7 +32,6 @@ func Tail(wg *sync.WaitGroup,pollInterval time.Duration,batchSize int,tag string
3332
log.Fatal(err)
3433
}
3534

36-
fmt.Println("Watching:", filePath)
3735

3836
var lastSize int = 0
3937

@@ -44,7 +42,6 @@ func Tail(wg *sync.WaitGroup,pollInterval time.Duration,batchSize int,tag string
4442
if event.Op&fsnotify.Write != fsnotify.Write {
4543
continue
4644
}
47-
fmt.Println("New write found")
4845
f, _ := os.Open(filePath)
4946
f.Seek(int64(lastSize), 0)
5047
scanner := bufio.NewScanner(f)
@@ -73,7 +70,6 @@ func Tail(wg *sync.WaitGroup,pollInterval time.Duration,batchSize int,tag string
7370
}
7471
batchedLogs = append(batchedLogs, entry)
7572

76-
fmt.Println("LOG CONTENT:", content)
7773
}
7874
lastSize = lastSize + len(line)
7975
}

frontend/src/components/LogFilter.tsx

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,15 @@ const levelColors: Record<LogLevel, string> = {
1818

1919
export function LogFilter({ selectedLevels, onToggleLevel }: LogFilterProps) {
2020
return (
21-
<div className="flex items-center gap-2">
22-
<span className="text-sm text-muted-foreground mr-1">Filter:</span>
21+
<div className="flex items-center gap-2 flex-wrap">
22+
{/* Hide label on mobile */}
23+
<span className="hidden sm:inline text-sm text-muted-foreground mr-1">
24+
Filter:
25+
</span>
26+
2327
{levels.map((level) => {
2428
const isActive = selectedLevels.includes(level);
29+
2530
return (
2631
<Button
2732
key={level}
@@ -30,8 +35,16 @@ export function LogFilter({ selectedLevels, onToggleLevel }: LogFilterProps) {
3035
onClick={() => onToggleLevel(level)}
3136
data-active={isActive}
3237
className={cn(
33-
'h-7 px-2.5 text-xs font-mono uppercase border-border/50 transition-all',
38+
// Base
39+
'font-mono uppercase border-border/50 transition-all',
40+
41+
// Mobile-friendly sizing
42+
'h-8 px-3 text-xs sm:h-7 sm:px-2.5',
43+
44+
// Active colors
3445
levelColors[level],
46+
47+
// Inactive state
3548
!isActive && 'text-muted-foreground hover:text-foreground'
3649
)}
3750
>

frontend/src/components/LogRow.tsx

Lines changed: 23 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,19 +8,33 @@ interface LogRowProps {
88
}
99

1010
export function LogRow({ log, isNew }: LogRowProps) {
11-
const formattedTime = format(new Date(log.timestamp), 'HH:mm:ss.SSS');
12-
const formattedDate = format(new Date(log.timestamp), 'MMM dd');
11+
const date = new Date(log.timestamp);
1312

1413
return (
15-
<div className={`log-row grid grid-cols-[140px_80px_1fr] gap-4 px-4 py-3 ${isNew ? 'animate-fade-in bg-primary/5' : ''}`}>
16-
<div className="flex items-center gap-2 text-muted-foreground font-mono text-sm">
17-
<span className="text-foreground/70">{formattedDate}</span>
18-
<span>{formattedTime}</span>
14+
<div
15+
className={[
16+
'grid grid-cols-[90px_64px_1fr] gap-3 px-4 py-1.5',
17+
'font-mono text-sm items-start',
18+
isNew ? 'animate-fade-in bg-primary/5' : ''
19+
].join(' ')}
20+
>
21+
{/* Timestamp (compact) */}
22+
<div className="text-muted-foreground leading-tight">
23+
<div className="text-foreground/70 text-xs">
24+
{format(date, 'MMM dd')}
25+
</div>
26+
<div className="text-xs">
27+
{format(date, 'HH:mm:ss')}
28+
</div>
1929
</div>
20-
<div className="flex items-center">
21-
<LogLevelBadge level={log.log_level} />
30+
31+
{/* Level (tight) */}
32+
<div className="flex items-start">
33+
<LogLevelBadge level={log.level} />
2234
</div>
23-
<div className="font-mono text-sm text-foreground/90 break-all">
35+
36+
{/* Message (gets space) */}
37+
<div className="text-foreground/90 whitespace-pre-wrap break-words leading-relaxed">
2438
{log.message}
2539
</div>
2640
</div>

frontend/src/components/LogTable.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ export function LogTable({ logs, selectedLevels, autoScroll, newLogIds }: LogTab
1616
console.log(logs)
1717

1818
const filteredLogs = logs.filter((log) =>
19-
selectedLevels.length === 0 || selectedLevels.includes(log.log_level)
19+
selectedLevels.length === 0 || selectedLevels.includes(log.level)
2020
);
2121

2222
useEffect(() => {
@@ -28,7 +28,7 @@ export function LogTable({ logs, selectedLevels, autoScroll, newLogIds }: LogTab
2828
return (
2929
<div className="flex-1 glass-card overflow-hidden flex flex-col">
3030
{/* Header */}
31-
<div className="grid grid-cols-[140px_80px_1fr] gap-4 px-4 py-3 border-b border-border/50 bg-muted/30">
31+
<div className="grid grid-cols-[90px_64px_1fr] gap-3 px-4 py-2 border-b border-border/50 bg-muted/30">
3232
<span className="text-xs font-medium text-muted-foreground uppercase tracking-wider">Timestamp</span>
3333
<span className="text-xs font-medium text-muted-foreground uppercase tracking-wider">Level</span>
3434
<span className="text-xs font-medium text-muted-foreground uppercase tracking-wider">Message</span>

0 commit comments

Comments
 (0)