go-ceph/common/log/log.go
Sven Anderson c610c53b54 common: implement a common log package
This change adds two log packages.  One for the external go-ceph
consumers under common/log, and one for the internal use within the
go-ceph code under internal/log.  The external package exports two
functions for consumers, SetWarnf() and SetDebugf(), that set a
logger for warnings and debug messages respectively. They take a
log.Printf compatible function as argument.

The internal package exports these functions as Warnf() and Debugf(),
which can be used by the go-ceph code to log warnings and debug
messages.

Signed-off-by: Sven Anderson <sven@redhat.com>
2022-02-23 16:30:08 +01:00

23 lines
556 B
Go

//go:build ceph_preview
// +build ceph_preview
// Package log allows to enable go-ceph logging and integrate it with the
// logging of the go-ceph consuming code.
package log
import (
intLog "github.com/ceph/go-ceph/internal/log"
)
// SetWarnf sets the log.Printf compatible receiver for warning logs.
// PREVIEW
func SetWarnf(f func(format string, v ...interface{})) {
intLog.Warnf = f
}
// SetDebugf sets the log.Printf compatible receiver for debug logs.
// PREVIEW
func SetDebugf(f func(format string, v ...interface{})) {
intLog.Debugf = f
}