Skip to content

Commit c739922

Browse files
committed
fix: add debug log to print logfile location
1 parent 1f3d945 commit c739922

File tree

3 files changed

+20
-7
lines changed

3 files changed

+20
-7
lines changed

go.mod

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
module github.com/rawnly/splash-cli
22

3-
go 1.21
3+
go 1.22.4
44

5-
toolchain go1.21.4
5+
toolchain go1.24.1
66

77
require (
88
github.com/AlecAivazis/survey/v2 v2.3.7
@@ -12,14 +12,15 @@ require (
1212
github.com/cli/browser v1.3.0
1313
github.com/eiannone/keyboard v0.0.0-20220611211555-0d226195f203
1414
github.com/getsentry/sentry-go v0.25.0
15-
github.com/google/uuid v1.5.0
15+
github.com/google/uuid v1.6.0
1616
github.com/mgutz/ansi v0.0.0-20200706080929-d51e80ef957d
1717
github.com/posthog/posthog-go v0.0.0-20230801140217-d607812dee69
1818
github.com/rawnly/go-wallpaper v1.0.2
1919
github.com/sirupsen/logrus v1.9.3
2020
github.com/spf13/cast v1.6.0
2121
github.com/spf13/cobra v1.8.0
2222
github.com/spf13/viper v1.18.2
23+
github.com/voxelite-ai/env v0.0.1
2324
)
2425

2526
require (

go.sum

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,8 @@ github.com/go-errors/errors v1.4.2/go.mod h1:sIVyrIiJhuEF+Pj9Ebtd6P/rEYROXFi3Bop
3434
github.com/google/go-cmp v0.5.9 h1:O2Tfq5qg4qc4AmwVlvv0oLiVAGB7enBSJ2x2DqQFi38=
3535
github.com/google/go-cmp v0.5.9/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
3636
github.com/google/uuid v1.3.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
37-
github.com/google/uuid v1.5.0 h1:1p67kYwdtXjb0gL0BPiP1Av9wiZPo5A8z2cWkTZ+eyU=
38-
github.com/google/uuid v1.5.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
37+
github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0=
38+
github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
3939
github.com/gopherjs/gopherjs v0.0.0-20181017120253-0766667cb4d1/go.mod h1:wJfORRmW1u3UXTncJ5qlYoELFm8eSnnEO6hX4iZ3EWY=
4040
github.com/hashicorp/hcl v1.0.0 h1:0Anlzjpi4vEasTeNFn2mLJgTSwt0+6sfsiTG8qcWGx4=
4141
github.com/hashicorp/hcl v1.0.0/go.mod h1:E5yfLk+7swimpb2L/Alb/PJmXilQ/rhwaUYs4T20WEQ=
@@ -111,11 +111,14 @@ github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/
111111
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
112112
github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
113113
github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU=
114-
github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk=
115114
github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo=
115+
github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg=
116+
github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
116117
github.com/subosito/gotenv v1.6.0 h1:9NlTDc1FTs4qu0DDq7AEtTPNw6SVm7uBMsUCUjABIf8=
117118
github.com/subosito/gotenv v1.6.0/go.mod h1:Dk4QP5c2W3ibzajGcXpNraDfq2IrhjMIvMSWPKKo0FU=
118119
github.com/urfave/cli v1.22.5/go.mod h1:Gos4lmkARVdJ6EkW0WaNv/tZAAMe9V7XWyB60NtXRu0=
120+
github.com/voxelite-ai/env v0.0.1 h1:Rpe2fdihal2q7S6KYVXk13ichEMOYJg/sX6//JhF4aw=
121+
github.com/voxelite-ai/env v0.0.1/go.mod h1:Ksei056hLOlNbmWVnY/fPwlz9FoLcDDdFhQEbF8bwcw=
119122
github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY=
120123
go.uber.org/multierr v1.11.0 h1:blXXJkSxSSfBVBlC76pxqeO+LN3aDfLQo+309xJstO0=
121124
go.uber.org/multierr v1.11.0/go.mod h1:20+QtiLqy0Nd6FdQB9TLXag12DsQkrbs3htMFfDN80Y=

setup.go

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,30 @@
11
package main
22

33
import (
4+
"fmt"
45
"os"
56

67
"github.com/getsentry/sentry-go"
78
"github.com/rawnly/splash-cli/config"
89
"github.com/rawnly/splash-cli/lib/analytics"
910
"github.com/sirupsen/logrus"
1011
"github.com/spf13/cobra"
12+
"github.com/voxelite-ai/env"
1113
)
1214

1315
// Setup the logs
1416
func setupLogs() {
17+
debug := env.Bool("SPLASH_CLI_DEBUG", false)
18+
logLevel := env.String("LOG_LEVEL", "info")
19+
1520
// You could set this to any `io.Writer` such as a file
1621
file, err := os.CreateTemp("", "splash-cli.log")
1722
if err == nil {
1823
logrus.SetOutput(file)
24+
25+
if debug {
26+
fmt.Println("Log file created at:", file.Name())
27+
}
1928
} else {
2029
logrus.Warn("Failed to log to file, using default stderr")
2130
}
@@ -35,7 +44,7 @@ func setupLogs() {
3544
}
3645

3746
if config.IsDebug() {
38-
if os.Getenv("LOG_LEVEL") == "trace" {
47+
if logLevel == "trace" {
3948
logrus.SetLevel(logrus.TraceLevel)
4049
} else {
4150
logrus.SetLevel(logrus.DebugLevel)

0 commit comments

Comments
 (0)