Files
Sebastiaan van Stijn 9e26694618 vendor: github.com/moby/policy-helpers b7c0b994300b
full diff: 824747bfdd...b7c0b99430

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2026-03-26 17:03:33 +01:00

29 lines
680 B
Go

// SPDX-FileCopyrightText: Copyright 2015-2025 go-swagger maintainers
// SPDX-License-Identifier: Apache-2.0
package debug
import (
"fmt"
"log"
"os"
"path/filepath"
"runtime"
)
var output = os.Stdout //nolint:gochecknoglobals // this is on purpose to be overridable during tests
// GetLogger provides a prefix debug logger.
func GetLogger(prefix string, debug bool) func(string, ...any) {
if debug {
logger := log.New(output, prefix+":", log.LstdFlags)
return func(msg string, args ...any) {
_, file1, pos1, _ := runtime.Caller(1)
logger.Printf("%s:%d: %s", filepath.Base(file1), pos1, fmt.Sprintf(msg, args...))
}
}
return func(_ string, _ ...any) {}
}