From 1de62aea0a77a79a4205950e9d590753cba09019 Mon Sep 17 00:00:00 2001 From: Anjan Nath Date: Mon, 4 Jul 2022 14:53:18 +0530 Subject: Fix error reported by go test This fixes the following error from go test ``` client/client.go:45:8: (*0xacab.org/leap/obfsvpn/client.Client).log call has arguments but no formatting directives ``` --- client/client.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/client/client.go b/client/client.go index 4b10ab2..c203e2b 100644 --- a/client/client.go +++ b/client/client.go @@ -42,7 +42,7 @@ func NewClient(kcp bool, socksAddr, obfs4Cert string) *Client { func (c *Client) Start() (bool, error) { defer func() { - c.log("STOPPED", "", nil) + c.log("STOPPED", "") }() if c.IsStarted() { -- cgit v1.2.3 From fbe1c1ec72293edcf61d7293f330e3d0ef6f2130 Mon Sep 17 00:00:00 2001 From: Anjan Nath Date: Mon, 4 Jul 2022 14:59:32 +0530 Subject: Use log.Printf only when a format is provided This adds a check to c.log to see if the format string is empty if its empty use log.Print and if a format is provided then use log.Printf --- client/client.go | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/client/client.go b/client/client.go index c203e2b..e67546a 100644 --- a/client/client.go +++ b/client/client.go @@ -98,8 +98,11 @@ func (c *Client) log(state string, format string, a ...interface{}) { c.EventLogger.Log(state, fmt.Sprintf(format, a...)) return } + if format == "" { + log.Print(a...) + return + } log.Printf(format, a...) - } func (c *Client) error(format string, a ...interface{}) { @@ -107,6 +110,10 @@ func (c *Client) error(format string, a ...interface{}) { c.EventLogger.Error(fmt.Sprintf(format, a...)) return } + if format == "" { + log.Print(a...) + return + } log.Printf(format, a...) } -- cgit v1.2.3