diff --git a/v8/client/settings.go b/v8/client/settings.go index 12c04c45..05b2ce4c 100644 --- a/v8/client/settings.go +++ b/v8/client/settings.go @@ -1,6 +1,9 @@ package client -import "log" +import ( + "fmt" + "log" +) // Settings holds optional client settings. type Settings struct { @@ -64,6 +67,6 @@ func (s *Settings) Logger() *log.Logger { // Log will write to the service's logger if it is configured. func (cl *Client) Log(format string, v ...interface{}) { if cl.settings.Logger() != nil { - cl.settings.Logger().Printf(format, v...) + cl.settings.Logger().Output(2, fmt.Sprintf(format, v...)) } } diff --git a/v8/examples/example-AD.go b/v8/examples/example-AD.go index 74c01bc2..408d8dbd 100644 --- a/v8/examples/example-AD.go +++ b/v8/examples/example-AD.go @@ -27,19 +27,20 @@ func main() { s := httpServer() defer s.Close() fmt.Printf("Listening on %s\n", s.URL) + l := log.New(os.Stderr, "GOKRB5 Client: ", log.Ldate|log.Ltime|log.Lshortfile) b, _ := hex.DecodeString(testdata.TESTUSER1_USERKRB5_AD_KEYTAB) kt := keytab.New() kt.Unmarshal(b) c, _ := config.NewFromString(testdata.TEST_KRB5CONF) - cl := client.NewWithKeytab("testuser1", "USER.GOKRB5", kt, c, client.DisablePAFXFAST(true)) + cl := client.NewWithKeytab("testuser1", "USER.GOKRB5", kt, c, client.DisablePAFXFAST(true), client.Logger(l)) httpRequest(s.URL, cl) b, _ = hex.DecodeString(testdata.TESTUSER2_USERKRB5_AD_KEYTAB) kt = keytab.New() kt.Unmarshal(b) c, _ = config.NewFromString(testdata.TEST_KRB5CONF) - cl = client.NewWithKeytab("testuser2", "USER.GOKRB5", kt, c, client.DisablePAFXFAST(true)) + cl = client.NewWithKeytab("testuser2", "USER.GOKRB5", kt, c, client.DisablePAFXFAST(true), client.Logger(l)) httpRequest(s.URL, cl) } @@ -48,7 +49,7 @@ func httpRequest(url string, cl *client.Client) { err := cl.Login() if err != nil { - l.Printf("Error on AS_REQ: %v\n", err) + l.Fatalf("Error on AS_REQ: %v\n", err) } spnegoCl := spnego.NewClient(cl, nil, "HTTP/host.res.gokrb5") diff --git a/v8/spnego/spnego.go b/v8/spnego/spnego.go index 7d1656e9..ebb818b9 100644 --- a/v8/spnego/spnego.go +++ b/v8/spnego/spnego.go @@ -92,7 +92,7 @@ func (s *SPNEGO) AcceptSecContext(ct gssapi.ContextToken) (bool, context.Context // Log will write to the service's logger if it is configured. func (s *SPNEGO) Log(format string, v ...interface{}) { if s.serviceSettings.Logger() != nil { - s.serviceSettings.Logger().Printf(format, v...) + s.serviceSettings.Logger().Output(2, fmt.Sprintf(format, v...)) } }