Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Logging Framework? #23

Closed
JanKoppe opened this issue Oct 29, 2020 · 3 comments
Closed

Logging Framework? #23

JanKoppe opened this issue Oct 29, 2020 · 3 comments

Comments

@JanKoppe
Copy link

Hey,

many thanks for this cool project! Will use it in a new project, where there will be a very huge amount of telemetry reports translated into Prometheus. Right now every message will generate a single log line, as shown here: https://github.com/hikhvar/mqtt2prometheus/blob/master/pkg/metrics/ingest.go#L130

I don't suppose there is a way to configure a less verbose logging level? If not, any plans to add some sort of basic logging framework?

hikhvar pushed a commit that referenced this issue Oct 29, 2020
As mentioned in #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.
@hikhvar
Copy link
Owner

hikhvar commented Oct 29, 2020

Hey, until now the logging was fine for me. Sure, with increasing load the current logging is sub optimal. I created a PR (#24 ) to introduce https://go.uber.org/zap as the logging library. I welcome feedback. The current log settings exposed to the user are the level (debug, info, warning, error, panic) with the default "info". The format can be choosen between "console":

2020-10-29T20:54:30+01:00	info	mqttclient/mqttClient.go:18	Connected to MQTT Broker
2020-10-29T20:54:30+01:00	info	mqttclient/mqttClient.go:19	Will subscribe to topic	{"topic": "v1/devices/me"}

and "json":

{"level":"info","ts":1604001457.4727054,"caller":"mqttclient/mqttClient.go:18","msg":"Connected to MQTT Broker"}
{"level":"info","ts":1604001457.4727683,"caller":"mqttclient/mqttClient.go:19","msg":"Will subscribe to topic","topic":"v1/devices/me"}

@hikhvar
Copy link
Owner

hikhvar commented Oct 29, 2020

Moreover, if you are able to speak about your project, I really like to hear about the cool problems people solve with this exporter.

@hikhvar
Copy link
Owner

hikhvar commented Nov 8, 2020

Implemented in Release v0.1.4.

@hikhvar hikhvar closed this as completed Nov 8, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants