mirror of
https://github.com/hikhvar/mqtt2prometheus.git
synced 2026-02-14 18:09:53 +00:00
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.
21 lines
367 B
Go
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,
|
|
}
|
|
}
|