// Logging helpers // SPDX-License-Identifier: GPL-3.0-or-later // Copyright (C) 2021-2024 Simon Ruderich package log import ( "fmt" "ruderich.org/simon/safcm" ) // LogFunc is a helper type to reduce typing. type LogFunc func(level safcm.LogLevel, msg string) type Logger struct { fun LogFunc } func NewLogger(fun LogFunc) *Logger { return &Logger{ fun: fun, } } func (l *Logger) Verbosef(format string, a ...interface{}) { l.log(safcm.LogVerbose, format, a...) } func (l *Logger) Debugf(format string, a ...interface{}) { l.log(safcm.LogDebug, format, a...) } func (l *Logger) Debug2f(format string, a ...interface{}) { l.log(safcm.LogDebug2, format, a...) } func (l *Logger) log(level safcm.LogLevel, format string, a ...interface{}) { l.fun(level, fmt.Sprintf(format, a...)) }