Files
mqtt2prometheus/pkg/config/runtime.go
Christoph Petrausch 126e13428b Use go.uber.org/zap for logging
As mentioned in https://github.com/hikhvar/mqtt2prometheus/issues/23, we
do not use any logging framework at all. This was fine for getting the
exporter startet. However, with inreasing load the logging must be
configureable. This PR is a start to replace all instances of
"log.Printf" with the zap logger. The current configuration parameters
are the log level and the log format (console, json). We might expose
the log configuration to the config file. But I think this is overkill
for the current state of the exporter.
2020-10-29 20:58:28 +01:00

21 lines
367 B
Go

package config
import "go.uber.org/zap"
// runtimeContext contains process global settings like the logger,
type runtimeContext struct {
logger *zap.Logger
}
func (r *runtimeContext) Logger() *zap.Logger {
return r.logger
}
var ProcessContext runtimeContext
func SetProcessContext(logger *zap.Logger) {
ProcessContext = runtimeContext{
logger: logger,
}
}