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

Add logger client #15

Closed
patoroco opened this issue Apr 11, 2019 · 2 comments · Fixed by #16
Closed

Add logger client #15

patoroco opened this issue Apr 11, 2019 · 2 comments · Fixed by #16

Comments

@patoroco
Copy link
Contributor

During development, should be really helpful to have a dummy statsd client that instead of try to send the metrics to the real statsd, it just print logs with the metrics that you're trying to send.

@wolph
Copy link
Owner

wolph commented Apr 11, 2019

That's easily done actually :)
First, set the statsd client to point to a non-existing statsd server. Since it uses udp it won't care if the server exists or not, it will silently fail.
Second, set the logging for statsd to info or higher.

So... something along these lines:

# Settings:
STATSD_HOST = '127.0.0.1'
STATSD_PORT = 12345

# Set the log level
import logging
logger = logging.getLogger('statsd')
logger.setLevel(logging.INFO)

# If you don't have any logging setup yet
logger.addHandler(logging.StreamHandler())

@patoroco
Copy link
Contributor Author

Sorry by my late answer, but I haven't had time to do it before...

Thanks to your response @wolph, I enabled the logs in my Django and it works as expected, but the client continued trying to send metrics to the server (with your config, to 127.0.0.1), so after read the statsd code, I've added this parameter in the #16, hoping to help more users :)

@wolph wolph closed this as completed in #16 Jul 12, 2019
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

Successfully merging a pull request may close this issue.

2 participants