Skip to content

Commit 1cf88fe

Browse files
committed
ccLogger: Cleanup printStr
1 parent 034f604 commit 1cf88fe

1 file changed

Lines changed: 11 additions & 21 deletions

File tree

ccLogger/cclogger.go

Lines changed: 11 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -229,16 +229,6 @@ func SetOutputFile(lvl string, logfile string) {
229229
}
230230
}
231231

232-
/* PRIVATE HELPER */
233-
234-
// FIXME: The printfStr function doesn't make any sense.
235-
// It is a whopping 2 characters less to write and more ambigious
236-
// than just writing fmt.Sprintf directly...
237-
// Return formatted string
238-
func printfStr(format string, v ...any) string {
239-
return fmt.Sprintf(format, v...)
240-
}
241-
242232
/* PRINT */
243233

244234
// Print logs to STDOUT without string formatting; application continues.
@@ -347,62 +337,62 @@ func Abortf(format string, v ...any) {
347337

348338
// ComponentPrint logs to INFO writer with a component prefix and string formatting; application continues.
349339
func ComponentPrintf(component, format string, v ...any) {
350-
InfoLog.Output(2, fmt.Sprintf("[%s] %s", component, printfStr(format, v...)))
340+
InfoLog.Output(2, fmt.Sprintf("[%s] %s", component, fmt.Sprintf(format, v...)))
351341
}
352342

353343
// Debugf logs to DEBUG writer with string formatting; application continues.
354344
// Used for logging additional information, primarily for development.
355345
func Debugf(format string, v ...any) {
356-
DebugLog.Output(2, printfStr(format, v...))
346+
DebugLog.Output(2, fmt.Sprintf(format, v...))
357347
}
358348

359349
// ComponentDebug logs to DEBUG writer with a component prefix and string formatting; application continues.
360350
func ComponentDebugf(component, format string, v ...any) {
361-
DebugLog.Output(2, fmt.Sprintf("[%s] %s", component, printfStr(format, v...)))
351+
DebugLog.Output(2, fmt.Sprintf("[%s] %s", component, fmt.Sprintf(format, v...)))
362352
}
363353

364354
// Infof log to INFO writer with string formatting; application continues.
365355
// Used for logging additional information, e.g. notable returns or common fail-cases.
366356
func Infof(format string, v ...any) {
367-
InfoLog.Output(2, printfStr(format, v...))
357+
InfoLog.Output(2, fmt.Sprintf(format, v...))
368358
}
369359

370360
// ComponentInfo logs to INFO writer with a component prefix and string formatting; application continues.
371361
func ComponentInfof(component, format string, v ...any) {
372-
InfoLog.Output(2, fmt.Sprintf("[%s] %s", component, printfStr(format, v...)))
362+
InfoLog.Output(2, fmt.Sprintf("[%s] %s", component, fmt.Sprintf(format, v...)))
373363
}
374364

375365
// Warnf logs to WARNING writer with string formatting; application continues.
376366
// Used for logging important information, e.g. uncommon edge-cases or administration related information.
377367
func Warnf(format string, v ...any) {
378-
WarnLog.Output(2, printfStr(format, v...))
368+
WarnLog.Output(2, fmt.Sprintf(format, v...))
379369
}
380370

381371
// ComponentWarn logs to WARNING writer with a component prefix and string formatting; application continues.
382372
func ComponentWarnf(component, format string, v ...any) {
383-
WarnLog.Output(2, fmt.Sprintf("[%s] %s", component, printfStr(format, v...)))
373+
WarnLog.Output(2, fmt.Sprintf("[%s] %s", component, fmt.Sprintf(format, v...)))
384374
}
385375

386376
// Errorf logs to ERROR writer with string formatting; application continues.
387377
// Used for logging errors, but code still can return default(s) or nil.
388378
func Errorf(format string, v ...any) {
389-
ErrLog.Output(2, printfStr(format, v...))
379+
ErrLog.Output(2, fmt.Sprintf(format, v...))
390380
}
391381

392382
// ComponentError logs to ERROR writer with a component prefix and string formatting; application continues.
393383
func ComponentErrorf(component, format string, v ...any) {
394-
ErrLog.Output(2, fmt.Sprintf("[%s] %s", component, printfStr(format, v...)))
384+
ErrLog.Output(2, fmt.Sprintf("[%s] %s", component, fmt.Sprintf(format, v...)))
395385
}
396386

397387
// Fatalf logs to CRITICAL writer with string formatting; application exits with error code 1.
398388
// Used for terminating on unexpected errors with date and code location.
399389
func Fatalf(format string, v ...any) {
400-
CritLog.Output(2, printfStr(format, v...))
390+
CritLog.Output(2, fmt.Sprintf(format, v...))
401391
os.Exit(1)
402392
}
403393

404394
// Panicf logs to PANIC function with string formatting; application exits with panic.
405395
// Used for terminating on unexpected errors with stacktrace.
406396
func Panicf(format string, v ...any) {
407-
panic(printfStr(format, v...))
397+
panic(fmt.Sprintf(format, v...))
408398
}

0 commit comments

Comments
 (0)