Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add log-file to proxy builder #316

Merged
merged 1 commit into from
Jan 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions cmd/gvproxy/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,12 @@ func main() {
}
}()
log.SetOutput(lf)

// If debug is set, lets seed the log file with some basic information
// about the environment and how it was called
log.Debugf("gvproxy version: %q", version.String())
log.Debugf("os: %q arch: %q", runtime.GOOS, runtime.GOARCH)
log.Debugf("command line: %q", os.Args)
}

log.Infof(version.String())
Expand Down
8 changes: 8 additions & 0 deletions pkg/types/gvproxy_command.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@ type GvproxyCommand struct {
// Map of different sockets provided by user (socket-type flag:socket)
sockets map[string]string

// Logfile where gvproxy should redirect logs
LogFile string

// File where gvproxy's pid is stored
PidFile string

Expand Down Expand Up @@ -179,6 +182,11 @@ func (c *GvproxyCommand) ToCmdline() []string {
args = append(args, "-pid-file", c.PidFile)
}

// log-file
if c.LogFile != "" {
args = append(args, "-log-file", c.LogFile)
}

return args
}

Expand Down
2 changes: 2 additions & 0 deletions test/basic_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,7 @@ var _ = ginkgo.Describe("command-line format", func() {
command.Debug = true
command.AddQemuSocket("tcp://0.0.0.0:1234")
command.PidFile = "~/gv-pidfile.txt"
command.LogFile = "~/gv.log"
command.AddForwardUser("demouser")

cmd := command.ToCmdline()
Expand All @@ -215,6 +216,7 @@ var _ = ginkgo.Describe("command-line format", func() {
"-listen-qemu", "tcp://0.0.0.0:1234",
"-forward-user", "demouser",
"-pid-file", "~/gv-pidfile.txt",
"-log-file", "~/gv.log",
}))
})
})
Loading