aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--utils/logger/logger.go10
1 files changed, 10 insertions, 0 deletions
diff --git a/utils/logger/logger.go b/utils/logger/logger.go
index 5fb415f..de2d69c 100644
--- a/utils/logger/logger.go
+++ b/utils/logger/logger.go
@@ -9,6 +9,8 @@ import (
"metachan/types"
)
+const prefixWidth = 15
+
func getTimestamp() string {
return time.Now().Format(time.RFC3339)
}
@@ -61,11 +63,19 @@ func Log(message interface{}, options types.LogOptions) {
builder.WriteString(" ")
if options.Prefix != "" {
+ totalWidth := len(options.Prefix)
+ padding := ""
+
+ if totalWidth < prefixWidth {
+ padding = strings.Repeat(" ", prefixWidth-totalWidth)
+ }
+
builder.WriteString(types.Cyan)
builder.WriteString("[")
builder.WriteString(options.Prefix)
builder.WriteString("]")
builder.WriteString(types.Reset)
+ builder.WriteString(padding)
builder.WriteString(" ")
}