Remove redundant constructor, h/t sergio

This commit is contained in:
Pim van Pelt
2025-11-15 22:41:57 +01:00
parent 27c7a5bcae
commit a0d5c61643
12 changed files with 48 additions and 44 deletions

View File

@@ -6,7 +6,7 @@ import (
"fmt"
"path/filepath"
"runtime"
"govpp-snmp-agentx/config"
)
@@ -16,15 +16,15 @@ func getCallerInfo() string {
if !ok {
return "unknown:unknown"
}
fn := runtime.FuncForPC(pc)
if fn == nil {
return "unknown:unknown"
}
funcName := filepath.Base(fn.Name())
fileName := filepath.Base(file)
return fmt.Sprintf("%s:%s", fileName, funcName)
}
@@ -49,4 +49,4 @@ func Debugf(format string, args ...interface{}) {
// Sync flushes any buffered log entries (no-op for fmt.Println)
func Sync() {
// No buffering with fmt.Println, so this is a no-op
}
}

View File

@@ -33,11 +33,11 @@ func TestPrintf(t *testing.T) {
if !strings.HasPrefix(output, "INFO ") {
t.Errorf("Expected output to start with 'INFO ', got: %s", output)
}
if !strings.Contains(output, "logger_test.go:logger.TestPrintf") {
t.Errorf("Expected output to contain caller info, got: %s", output)
}
if !strings.Contains(output, "test message: hello") {
t.Errorf("Expected output to contain message, got: %s", output)
}
@@ -71,7 +71,7 @@ func TestDebugfWithDebugEnabled(t *testing.T) {
if !strings.HasPrefix(output, "DEBUG ") {
t.Errorf("Expected output to start with 'DEBUG ', got: %s", output)
}
if !strings.Contains(output, "debug message: test") {
t.Errorf("Expected output to contain message, got: %s", output)
}
@@ -110,4 +110,4 @@ func TestDebugfWithDebugDisabled(t *testing.T) {
func TestSync(t *testing.T) {
// Test that Sync doesn't panic (it's a no-op now)
Sync()
}
}