Skip to content

Commit

Permalink
Use a string builder for a log message
Browse files Browse the repository at this point in the history
  • Loading branch information
xyproto committed Jun 25, 2024
1 parent 05f161b commit 10e8f6d
Showing 1 changed file with 15 additions and 7 deletions.
22 changes: 15 additions & 7 deletions engine/funcmap.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (
"net/http"
"strings"

log "github.com/sirupsen/logrus"
"github.com/sirupsen/logrus"
"github.com/xyproto/datablock"
)

Expand Down Expand Up @@ -36,16 +36,24 @@ func (ac *Config) Lua2funcMap(w http.ResponseWriter, req *http.Request, filename
return
}
if ac.debugMode && ac.verboseMode {
s := "These functions from " + luafilename
s += " are useable for " + filename + ": "
var sb strings.Builder
sb.WriteString("These functions from ")
sb.WriteString(luafilename)
sb.WriteString(" are useable for ")
sb.WriteString(filename)
sb.WriteString(": ")
// Create a comma separated list of the available functions
first := true
for key := range funcs {
s += key + ", "
if first {
first = false
} else {
sb.WriteString(", ")
}
sb.WriteString(key)
}
// Remove the final comma
s = strings.TrimSuffix(s, ", ")
// Output the message
log.Info(s)
logrus.Info(sb.String())
}
}
funcMapChan <- funcs
Expand Down

0 comments on commit 10e8f6d

Please sign in to comment.