processor/trace.go GO 97 lines View on github.com → Search inside
1package processor23import (4	"fmt"5	"io"6	"os"7	"time"8)910type traceLevel uint81112const (13	levelTrace traceLevel = iota + 114	levelDebug15	levelWarn16	levelError17)1819func (tl traceLevel) String() string {20	switch tl {21	case levelTrace:22		return "TRACE"23	case levelDebug:24		return "DEBUG"25	case levelWarn:26		return "WARN"27	case levelError:28		return "ERROR"29	default:30		return ""31	}32}3334// Get the time as standard UTC/Zulu format35func getFormattedTime() string {36	return time.Now().UTC().Format(time.RFC3339)37}3839func prepareMsg(template string, args []any) string {40	if len(args) == 0 {41		return template42	}4344	return fmt.Sprintf(template, args...)45}4647func doPrint(dst io.Writer, level traceLevel, template string, args []any) {48	_, _ = fmt.Fprintf(dst, "%s %s: %s\n", level, getFormattedTime(), prepareMsg(template, args))49}5051// Prints a message to stdout if flag to enable warning output is set52func printWarn(msg string) {53	if Verbose {54		doPrint(os.Stdout, levelWarn, msg, nil)55	}56}5758// Prints a message to stdout if flag to enable warning output is set59func printWarnF(msg string, args ...any) {60	if Verbose {61		doPrint(os.Stdout, levelWarn, msg, args)62	}63}6465// Prints a message to stdout if flag to enable debug output is set66func printDebug(msg string) {67	if Debug {68		doPrint(os.Stdout, levelDebug, msg, nil)69	}70}7172// Prints a message to stdout if flag to enable debug output is set73func printDebugF(msg string, args ...any) {74	if Debug {75		doPrint(os.Stdout, levelDebug, msg, args)76	}77}7879// Prints a message to stdout if flag to enable trace output is set80func printTrace(msg string) {81	if Trace {82		doPrint(os.Stdout, levelTrace, msg, nil)83	}84}8586// Prints a message to stdout if flag to enable trace output is set87func printTraceF(msg string, args ...any) {88	if Trace {89		doPrint(os.Stdout, levelTrace, msg, args)90	}91}9293// Used when explicitly for os.exit output when crashing out94func printError(msg string) {95	doPrint(os.Stderr, levelError, msg, nil)96}

Code quality findings 1

Blank identifier discarding results; verify intentional ignoring of return values
warning correctness blank-identifier-discard
_, _ = fmt.Fprintf(dst, "%s %s: %s\n", level, getFormattedTime(), prepareMsg(template, args))

Get this view in your editor

Same data, no extra tab — call code_get_file + code_get_findings over MCP from Claude/Cursor/Copilot.