From 4befb94b70ebb863498f9ee42f719fd87928b5be Mon Sep 17 00:00:00 2001
From: Jono Wenger <jono@elixxir.io>
Date: Tue, 13 Sep 2022 18:58:11 -0700
Subject: [PATCH] Fix logging object naming

---
 main.go         |  3 +--
 wasm/logging.go | 17 +++++++++--------
 2 files changed, 10 insertions(+), 10 deletions(-)

diff --git a/main.go b/main.go
index 46a170cf..2a4e56de 100644
--- a/main.go
+++ b/main.go
@@ -22,8 +22,7 @@ import (
 func init() {
 	// Overwrites setting the log level to INFO done in bindings so that the
 	// Javascript console can be used
-	ll := &wasm.LogListener{
-		Threshold: jww.LevelInfo, Value: js.Global().Get("console")}
+	ll := wasm.NewJsConsoleLogListener(jww.LevelInfo)
 	jww.SetLogListeners(ll.Listen)
 	jww.SetStdoutThreshold(jww.LevelFatal + 1)
 }
diff --git a/wasm/logging.go b/wasm/logging.go
index 450d8137..2f636d1b 100644
--- a/wasm/logging.go
+++ b/wasm/logging.go
@@ -56,7 +56,7 @@ func LogLevel(_ js.Value, args []js.Value) interface{} {
 	jww.SetLogThreshold(threshold)
 	jww.SetFlags(log.LstdFlags | log.Lmicroseconds)
 
-	ll := NewLogListener(threshold, js.Global().Get("console"))
+	ll := NewJsConsoleLogListener(threshold)
 	logListeners = append(logListeners, ll.Listen)
 	jww.SetLogListeners(logListeners...)
 	jww.SetStdoutThreshold(jww.LevelFatal + 1)
@@ -179,8 +179,8 @@ func (c *console) Write(p []byte) (n int, err error) {
 	return len(p), nil
 }
 
-// LogListener redirects log output to the Javascript console.
-type LogListener struct {
+// JsConsoleLogListener redirects log output to the Javascript console.
+type JsConsoleLogListener struct {
 	jww.Threshold
 	js.Value
 
@@ -194,10 +194,11 @@ type LogListener struct {
 	def      *console
 }
 
-// NewLogListener initialises a new log listener that listener for the specific
-// threshold and prints the logs to the Javascript console.
-func NewLogListener(threshold jww.Threshold, consoleObj js.Value) *LogListener {
-	return &LogListener{
+// NewJsConsoleLogListener initialises a new log listener that listener for the
+// specific threshold and prints the logs to the Javascript console.
+func NewJsConsoleLogListener(threshold jww.Threshold) *JsConsoleLogListener {
+	consoleObj := js.Global().Get("console")
+	return &JsConsoleLogListener{
 		Threshold: threshold,
 		Value:     consoleObj,
 		trace:     &console{"debug", consoleObj},
@@ -213,7 +214,7 @@ func NewLogListener(threshold jww.Threshold, consoleObj js.Value) *LogListener {
 
 // Listen is called for every logging event. This function adheres to the
 // [jwalterweatherman.LogListener] type.
-func (ll *LogListener) Listen(t jww.Threshold) io.Writer {
+func (ll *JsConsoleLogListener) Listen(t jww.Threshold) io.Writer {
 	if t < ll.Threshold {
 		return nil
 	}
-- 
GitLab