Log game output to disk, update deps for 1.14.0
This commit is contained in:
parent
8595ad0eba
commit
e20c694d93
|
@ -26,6 +26,8 @@ import (
|
|||
"git.kirsle.net/SketchyMaze/doodle/pkg/sound"
|
||||
"git.kirsle.net/SketchyMaze/doodle/pkg/sprites"
|
||||
"git.kirsle.net/SketchyMaze/doodle/pkg/usercfg"
|
||||
"git.kirsle.net/SketchyMaze/doodle/pkg/userdir"
|
||||
golog "git.kirsle.net/go/log"
|
||||
"git.kirsle.net/go/render"
|
||||
"git.kirsle.net/go/render/sdl"
|
||||
"github.com/urfave/cli/v2"
|
||||
|
@ -84,6 +86,11 @@ func main() {
|
|||
Aliases: []string{"d"},
|
||||
Usage: "enable debug level logging",
|
||||
},
|
||||
&cli.StringFlag{
|
||||
Name: "log",
|
||||
Aliases: []string{"o"},
|
||||
Usage: "path on disk to copy the game's standard output logs (default goes to your game profile directory)",
|
||||
},
|
||||
&cli.StringFlag{
|
||||
Name: "pprof",
|
||||
Usage: "record pprof metrics to a filename",
|
||||
|
@ -122,6 +129,11 @@ func main() {
|
|||
}
|
||||
|
||||
app.Action = func(c *cli.Context) error {
|
||||
// Write the game's log to disk.
|
||||
if err := initLogFile(c.String("log")); err != nil {
|
||||
log.Error("Couldn't write logs to disk: %s", err)
|
||||
}
|
||||
|
||||
log.Info("Starting %s %s", app.Name, app.Version)
|
||||
|
||||
// Print registration information, + also this sets the DefaultAuthor field.
|
||||
|
@ -298,3 +310,18 @@ func setResolution(value string) error {
|
|||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func initLogFile(filename string) error {
|
||||
// Default log file to disk goes to your profile directory.
|
||||
if filename == "" {
|
||||
filename = userdir.LogFile
|
||||
}
|
||||
|
||||
fh, err := golog.NewFileTee(filename)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
log.Logger.Config.Writer = fh
|
||||
return nil
|
||||
}
|
||||
|
|
13
go.mod
13
go.mod
|
@ -5,8 +5,8 @@ go 1.22.0
|
|||
require (
|
||||
git.kirsle.net/SketchyMaze/dpp v0.0.0-00010101000000-000000000000
|
||||
git.kirsle.net/go/audio v0.0.0-20231209225956-d0ed23cf73c8
|
||||
git.kirsle.net/go/log v0.0.0-20200902035305-70ac2848949b
|
||||
git.kirsle.net/go/render v0.0.0-20240212004549-a8da853de086
|
||||
git.kirsle.net/go/log v0.0.0-20240505021515-9c747daf9e9a
|
||||
git.kirsle.net/go/render v0.0.0-20240420054513-c624cc08cde4
|
||||
git.kirsle.net/go/ui v0.0.0-20231209230025-20a9d7bdff85
|
||||
github.com/aichaos/rivescript-go v0.4.0
|
||||
github.com/dgrijalva/jwt-go v3.2.0+incompatible
|
||||
|
@ -14,7 +14,7 @@ require (
|
|||
github.com/gen2brain/dlgs v0.0.0-20220603100644-40c77870fa8d
|
||||
github.com/google/uuid v1.6.0
|
||||
github.com/kirsle/configdir v0.0.0-20170128060238-e45d2f54772f
|
||||
github.com/urfave/cli/v2 v2.27.1
|
||||
github.com/urfave/cli/v2 v2.27.2
|
||||
github.com/veandco/go-sdl2 v0.4.38
|
||||
golang.org/x/image v0.15.0
|
||||
)
|
||||
|
@ -23,14 +23,15 @@ require (
|
|||
github.com/cpuguy83/go-md2man/v2 v2.0.4 // indirect
|
||||
github.com/dlclark/regexp2 v1.11.0 // indirect
|
||||
github.com/go-sourcemap/sourcemap v2.1.4+incompatible // indirect
|
||||
github.com/google/pprof v0.0.0-20240416155748-26353dc0451f // indirect
|
||||
github.com/google/pprof v0.0.0-20240430035430-e4905b036c4e // indirect
|
||||
github.com/gopherjs/gopherjs v1.17.2 // indirect
|
||||
github.com/mattn/go-shellwords v1.0.12 // indirect
|
||||
github.com/russross/blackfriday/v2 v2.1.0 // indirect
|
||||
github.com/tomnomnom/xtermcolor v0.0.0-20160428124646-b78803f00a7e // indirect
|
||||
github.com/xrash/smetrics v0.0.0-20240312152122-5f08fbb34913 // indirect
|
||||
golang.org/x/crypto v0.22.0 // indirect
|
||||
golang.org/x/sys v0.19.0 // indirect
|
||||
golang.org/x/sys v0.20.0 // indirect
|
||||
golang.org/x/term v0.19.0 // indirect
|
||||
golang.org/x/text v0.14.0 // indirect
|
||||
golang.org/x/text v0.15.0 // indirect
|
||||
)
|
||||
|
||||
|
|
17
go.sum
17
go.sum
|
@ -1,5 +1,14 @@
|
|||
git.kirsle.net/go/audio v0.0.0-20231209225956-d0ed23cf73c8 h1:Zw2Hav5G+IY3q1UYo2Zq8WbtuS1AHlLDoxUss6Tp8qo=
|
||||
git.kirsle.net/go/audio v0.0.0-20231209225956-d0ed23cf73c8/go.mod h1:RD2Kyiy2lgayzQYmrh0S0/HLiq4XgAldt7MISCvtX5Y=
|
||||
git.kirsle.net/go/log v0.0.0-20200902035305-70ac2848949b h1:TDxEEWOJqMzsu9JW8/QgmT1lgQ9WD2KWlb2lKN/Ql2o=
|
||||
git.kirsle.net/go/log v0.0.0-20200902035305-70ac2848949b/go.mod h1:jl+Qr58W3Op7OCxIYIT+b42jq8xFncJXzPufhrvza7Y=
|
||||
git.kirsle.net/go/log v0.0.0-20240505021515-9c747daf9e9a h1:IHdqfXu7oqOPPotdzTFpmjJrryNWAad7eiS5BvGwXQA=
|
||||
git.kirsle.net/go/log v0.0.0-20240505021515-9c747daf9e9a/go.mod h1:1hGKQt1uiIwPKfVl/fLO32Xr42+5BZl4jEwFeRns9cM=
|
||||
git.kirsle.net/go/render v0.0.0-20220505053906-129a24300dfa/go.mod h1:ss7pvZbGWrMaDuZwyUTjV9+T0AJwAkxZZHwMFsvHrkk=
|
||||
git.kirsle.net/go/render v0.0.0-20240420054513-c624cc08cde4 h1:CuXqMfRfBoEudLVInutZOg9ZKHVrxTYK9LxhuhfsA4A=
|
||||
git.kirsle.net/go/render v0.0.0-20240420054513-c624cc08cde4/go.mod h1:ss7pvZbGWrMaDuZwyUTjV9+T0AJwAkxZZHwMFsvHrkk=
|
||||
git.kirsle.net/go/ui v0.0.0-20231209230025-20a9d7bdff85 h1:ien/5H9hojZaLIwnWZvLbrYLZZBBXETC7eUv1OmYlmg=
|
||||
git.kirsle.net/go/ui v0.0.0-20231209230025-20a9d7bdff85/go.mod h1:EXFrvIXSHnT2TsCnttrFasKo9BTiBtN5UbXfHGaTCa0=
|
||||
github.com/aichaos/rivescript-go v0.4.0 h1:+bG6h5v6IOmfyirIm1zQTiXu/dE6uWayDI/0/6yPu/s=
|
||||
github.com/aichaos/rivescript-go v0.4.0/go.mod h1:mf+QIyHz1dB4hmIZ6HkTF/rHqPOP9THViNbpMfN8iNU=
|
||||
github.com/chzyer/logex v1.2.0/go.mod h1:9+9sk7u7pGNWYMkh0hdiL++6OeibzJccyQU4p4MedaY=
|
||||
|
@ -48,6 +57,8 @@ github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/
|
|||
github.com/google/pprof v0.0.0-20230207041349-798e818bf904/go.mod h1:uglQLonpP8qtYCYyzA+8c/9qtqgA3qsXGYqCPKARAFg=
|
||||
github.com/google/pprof v0.0.0-20240416155748-26353dc0451f h1:WpZiq8iqvGjJ3m3wzAVKL6+0vz7VkE79iSy9GII00II=
|
||||
github.com/google/pprof v0.0.0-20240416155748-26353dc0451f/go.mod h1:kf6iHlnVGwgKolg33glAes7Yg/8iWP8ukqeldJSO7jw=
|
||||
github.com/google/pprof v0.0.0-20240430035430-e4905b036c4e h1:RsXNnXE59RTt8o3DcA+w7ICdRfR2l+Bb5aE0YMpNTO8=
|
||||
github.com/google/pprof v0.0.0-20240430035430-e4905b036c4e/go.mod h1:kf6iHlnVGwgKolg33glAes7Yg/8iWP8ukqeldJSO7jw=
|
||||
github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0=
|
||||
github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
|
||||
github.com/gopherjs/gopherjs v1.17.2 h1:fQnZVsXk8uxXIStYb0N4bGk7jeyTalG/wsZjQ25dO0g=
|
||||
|
@ -88,6 +99,8 @@ github.com/tomnomnom/xtermcolor v0.0.0-20160428124646-b78803f00a7e h1:Ee+VZw13r9
|
|||
github.com/tomnomnom/xtermcolor v0.0.0-20160428124646-b78803f00a7e/go.mod h1:fSIW/szJHsRts/4U8wlMPhs+YqJC+7NYR+Qqb1uJVpA=
|
||||
github.com/urfave/cli/v2 v2.27.1 h1:8xSQ6szndafKVRmfyeUMxkNUJQMjL1F2zmsZ+qHpfho=
|
||||
github.com/urfave/cli/v2 v2.27.1/go.mod h1:8qnjx1vcq5s2/wpsqoZFndg2CE5tNFyrTvS6SinrnYQ=
|
||||
github.com/urfave/cli/v2 v2.27.2 h1:6e0H+AkS+zDckwPCUrZkKX38mRaau4nL2uipkJpbkcI=
|
||||
github.com/urfave/cli/v2 v2.27.2/go.mod h1:g0+79LmHHATl7DAcHO99smiR/T7uGLw84w8Y42x+4eM=
|
||||
github.com/veandco/go-sdl2 v0.4.1/go.mod h1:FB+kTpX9YTE+urhYiClnRzpOXbiWgaU3+5F2AB78DPg=
|
||||
github.com/veandco/go-sdl2 v0.4.36/go.mod h1:OROqMhHD43nT4/i9crJukyVecjPNYYuCofep6SNiAjY=
|
||||
github.com/veandco/go-sdl2 v0.4.38 h1:lx8syOA2ccXlgViYkQe2Kn/4xt+p9mdd1Qc/yYMrmSo=
|
||||
|
@ -141,6 +154,8 @@ golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBc
|
|||
golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.19.0 h1:q5f1RH2jigJ1MoAWp2KTp3gm5zAGFUTarQZ5U386+4o=
|
||||
golang.org/x/sys v0.19.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
|
||||
golang.org/x/sys v0.20.0 h1:Od9JTbYCk261bKm4M/mw7AklTlFYIa0bIp9BgSm1S8Y=
|
||||
golang.org/x/sys v0.20.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
|
||||
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
|
||||
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
|
||||
golang.org/x/term v0.5.0/go.mod h1:jMB1sMXY+tzblOD4FWmEbocvup2/aLOaQEp7JmGp78k=
|
||||
|
@ -156,6 +171,8 @@ golang.org/x/text v0.7.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8=
|
|||
golang.org/x/text v0.12.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE=
|
||||
golang.org/x/text v0.14.0 h1:ScX5w1eTa3QqT8oi6+ziP7dTV1S2+ALU0bI+0zXKWiQ=
|
||||
golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU=
|
||||
golang.org/x/text v0.15.0 h1:h1V/4gjBv8v9cjcR6+AR5+/cIYK5N/WAgiv4xlsEtAk=
|
||||
golang.org/x/text v0.15.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU=
|
||||
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
|
||||
golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
|
||||
golang.org/x/tools v0.0.0-20201224043029-2b0845dc783e/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA=
|
||||
|
|
|
@ -22,6 +22,7 @@ var (
|
|||
CampaignDirectory string
|
||||
ScreenshotDirectory string
|
||||
SaveFile string
|
||||
LogFile string
|
||||
|
||||
CacheDirectory string
|
||||
FontDirectory string
|
||||
|
@ -43,6 +44,7 @@ func init() {
|
|||
CampaignDirectory = configdir.LocalConfig(ConfigDirectoryName, "campaigns")
|
||||
ScreenshotDirectory = configdir.LocalConfig(ConfigDirectoryName, "screenshots")
|
||||
SaveFile = configdir.LocalConfig(ConfigDirectoryName, "savegame.json")
|
||||
LogFile = configdir.LocalConfig(ConfigDirectoryName, "logfile.txt")
|
||||
|
||||
// Cache directory to extract font files to.
|
||||
CacheDirectory = configdir.LocalCache(ConfigDirectoryName)
|
||||
|
|
Loading…
Reference in New Issue
Block a user