AUTH-2815 add the log file to support the config.yaml file

added small delay to handle the possiblity of the server not being started yet
This commit is contained in:
Dalton 2020-06-16 10:33:03 -05:00 committed by Dalton Cherry
parent 3ec500bdbb
commit 6e5ccd7c85
2 changed files with 16 additions and 5 deletions

View File

@ -215,7 +215,12 @@ func Init(v string, s, g chan struct{}) {
func createLogger(c *cli.Context, isTransport bool) (logger.Service, error) { func createLogger(c *cli.Context, isTransport bool) (logger.Service, error) {
loggerOpts := []logger.Option{} loggerOpts := []logger.Option{}
logPath := c.String(logDirectoryFlag)
logPath := c.String("logfile")
if logPath != "" {
logPath = c.String(logDirectoryFlag)
}
if logPath != "" { if logPath != "" {
loggerOpts = append(loggerOpts, logger.DefaultFile(logPath)) loggerOpts = append(loggerOpts, logger.DefaultFile(logPath))
} }
@ -833,12 +838,17 @@ func tunnelFlags(shouldHide bool) []cli.Flag {
Hidden: shouldHide, Hidden: shouldHide,
}), }),
altsrc.NewStringFlag(&cli.StringFlag{ altsrc.NewStringFlag(&cli.StringFlag{
Name: logDirectoryFlag, Name: "logfile",
Aliases: []string{"logfile"}, // This flag used to be called logfile when it was a single file Usage: "Save application log to this file for reporting issues.",
Usage: "Save application log to this directory for reporting issues.",
EnvVars: []string{"TUNNEL_LOGFILE"}, EnvVars: []string{"TUNNEL_LOGFILE"},
Hidden: shouldHide, Hidden: shouldHide,
}), }),
altsrc.NewStringFlag(&cli.StringFlag{
Name: logDirectoryFlag,
Usage: "Save application log to this directory for reporting issues.",
EnvVars: []string{"TUNNEL_LOGDIRECTORY"},
Hidden: shouldHide,
}),
altsrc.NewIntFlag(&cli.IntFlag{ altsrc.NewIntFlag(&cli.IntFlag{
Name: "ha-connections", Name: "ha-connections",
Value: 4, Value: 4,

View File

@ -6,6 +6,7 @@ import (
"net" "net"
"net/http" "net/http"
"testing" "testing"
"time"
"github.com/stretchr/testify/assert" "github.com/stretchr/testify/assert"
"golang.org/x/net/proxy" "golang.org/x/net/proxy"
@ -58,7 +59,6 @@ func startTestServer(t *testing.T, httpHandler func(w http.ResponseWriter, r *ht
// start the servers // start the servers
go http.ListenAndServe(":8085", mux) go http.ListenAndServe(":8085", mux)
} }
func respondWithJSON(w http.ResponseWriter, v interface{}, status int) { func respondWithJSON(w http.ResponseWriter, v interface{}, status int) {
@ -78,6 +78,7 @@ func OkJSONResponseHandler(w http.ResponseWriter, r *http.Request) {
func TestSocksConnection(t *testing.T) { func TestSocksConnection(t *testing.T) {
startTestServer(t, OkJSONResponseHandler) startTestServer(t, OkJSONResponseHandler)
time.Sleep(100 * time.Millisecond)
b := sendSocksRequest(t) b := sendSocksRequest(t)
assert.True(t, len(b) > 0, "no data returned!") assert.True(t, len(b) > 0, "no data returned!")