diff options
Diffstat (limited to 'internal/logging/logging.go')
| -rw-r--r-- | internal/logging/logging.go | 41 |
1 files changed, 20 insertions, 21 deletions
diff --git a/internal/logging/logging.go b/internal/logging/logging.go index 2e4bbc8..80231ab 100644 --- a/internal/logging/logging.go +++ b/internal/logging/logging.go @@ -1,18 +1,18 @@ package logging import ( - "fmt" - "log" + "fmt" + "log" ) // ANSI color utilities shared across Hexai. const ( - AnsiBgBlack = "\x1b[40m" - AnsiGrey = "\x1b[90m" - AnsiCyan = "\x1b[36m" - AnsiGreen = "\x1b[32m" - AnsiRed = "\x1b[31m" - AnsiReset = "\x1b[0m" + AnsiBgBlack = "\x1b[40m" + AnsiGrey = "\x1b[90m" + AnsiCyan = "\x1b[36m" + AnsiGreen = "\x1b[32m" + AnsiRed = "\x1b[31m" + AnsiReset = "\x1b[0m" ) // AnsiBase is the default style: black background + grey foreground. @@ -26,11 +26,11 @@ func Bind(l *log.Logger) { std = l } // Logf prints a formatted message with a module prefix and base ANSI style. func Logf(prefix, format string, args ...any) { - if std == nil { - return - } - msg := fmt.Sprintf(format, args...) - std.Print(AnsiBase + prefix + msg + AnsiReset) + if std == nil { + return + } + msg := fmt.Sprintf(format, args...) + std.Print(AnsiBase + prefix + msg + AnsiReset) } // Logging configuration for previews (shared) @@ -42,12 +42,11 @@ func SetLogPreviewLimit(n int) { logPreviewLimit = n } // PreviewForLog returns the string truncated to the configured preview limit. func PreviewForLog(s string) string { - if logPreviewLimit > 0 { - if len(s) <= logPreviewLimit { - return s - } - return s[:logPreviewLimit] + "…" - } - return s + if logPreviewLimit > 0 { + if len(s) <= logPreviewLimit { + return s + } + return s[:logPreviewLimit] + "…" + } + return s } - |
