From 56687774eb83b9579ccde105101883e482ef5a5e Mon Sep 17 00:00:00 2001
From: joshemb <josh@elixxir.io>
Date: Thu, 19 Jan 2023 15:10:53 -0800
Subject: [PATCH] Fix bugs in emoji logging

---
 emoji/main.go  | 12 +++++-------
 emoji/utils.go |  2 +-
 2 files changed, 6 insertions(+), 8 deletions(-)

diff --git a/emoji/main.go b/emoji/main.go
index 2a061b09..fec1a192 100644
--- a/emoji/main.go
+++ b/emoji/main.go
@@ -53,8 +53,8 @@ var sanitizeEmojis = &cobra.Command{
 	Run: func(cmd *cobra.Command, args []string) {
 
 		// Initialize the logging if set
-		if viper.GetInt(logLevelFlag) != 0 {
-			initLog(1, "emoji-sanitization.log")
+		if logFile := viper.GetString(logFileFlag); logFile != "" {
+			initLog(viper.GetInt(logFileFlag), logFile)
 		}
 
 		// Retrieve emoji-mart file from URL
@@ -110,9 +110,8 @@ func init() {
 	}
 
 	sanitizeEmojis.PersistentFlags().StringP(logFileFlag, "l", "",
-		"Path to the log output path. If logLevel is not set, this flag "+
-			"wll be ignored. By default, this flag is not set so a log will not "+
-			"be created unless specified.")
+		"Path to the log output path. By default, this flag is not set "+
+			"so a log will not be created unless specified.")
 	err = viper.BindPFlag(logFileFlag, sanitizeEmojis.PersistentFlags().
 		Lookup(logFileFlag))
 	if err != nil {
@@ -121,8 +120,7 @@ func init() {
 	}
 
 	sanitizeEmojis.PersistentFlags().IntP(logLevelFlag, "v", 0,
-		"Verbosity level of logging. If not set, this defaults to 0 and will "+
-			"not create logs. ")
+		"Verbosity level of logging. This defaults to 0. ")
 	err = viper.BindPFlag(logLevelFlag, sanitizeEmojis.PersistentFlags().
 		Lookup(logLevelFlag))
 	if err != nil {
diff --git a/emoji/utils.go b/emoji/utils.go
index 034c7bfb..b50d0229 100644
--- a/emoji/utils.go
+++ b/emoji/utils.go
@@ -15,7 +15,7 @@ import (
 )
 
 // initLog will enable JWW logging.
-func initLog(threshold uint, logPath string) {
+func initLog(threshold int, logPath string) {
 	if logPath != "-" && logPath != "" {
 		// Disable stdout output
 		jww.SetStdoutOutput(io.Discard)
-- 
GitLab