This is a pre-production deployment of Warehouse. Changes made here affect the production instance of PyPI (
Help us improve Python packaging - Donate today!

logd python library

Project Description


pylogd is a python interface to logd. It pushes log messages or statistics to logd over a UDP socket.


pylogd ships various utilities to deal with logd, python logging handlers, and a Stats object which makes it trivial to record statistics.


To log to logd using the python logging module, create a new handler with your logd server’s host and port and then set it up as your default logging handler:

from pylogd.handlers import PylogdHandler
handler = PylogdHandler('mylogpath.log', '', 8126)
logger = logging.getLogger()

Now, subsequent calls to logger.(error|warn|etc) will log to your logd server. If you do this on the root logger (getLogger('base')), it will apply to all subsequently created loggers.

To delete a log, use pylogd.delete_log with the host and port of logd:

from pylogd import delete_log
delete_log('mylogpath.log', host='', 8126)


To use stats, create a stats handle:

from pylogd.stats import Logd
stats = Logd('', 8126)

You can also supply an optional prefix which will be prepended to all of your stats, so that multiple applications can use the same logd/graphite server without having to repeate their per-app key for every stats call.

Once you have a Logd object, you can increment & decrment counters (with an optional sample rate):

stats.change_by('my.counter', 10)
stats.decrement('my.counter', 0.05) # only update 5% of the time

You can also set the value of a meter:

stats.set('my.meter', 30)
stats.set('my.meter', 30, 0.25) # only set 25% of the time

There’s a basic time interface as well as a convenient timer interface:

stats.time('my.timer', 11.43) # time manually

# automatically start & stop a timer

# time this function with a 10% sample rate
@stats.timed('my.long_operation', 0.1)
def long_operation():

# accumulate time done doing various similar tasks

# send this timing information to logd

twisted support

For twisted users, use pylogd.twisted (included) instead of pylogd, and note that log messages and stats will not go to logd until the reactor has been started.

Release History

Release History

This version
History Node


Download Files

Download Files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

File Name & Checksum SHA256 Checksum Help Version File Type Upload Date
pylogd-0.2.tar.gz (6.5 kB) Copy SHA256 Checksum SHA256 Source Jan 13, 2012

Supported By

WebFaction WebFaction Technical Writing Elastic Elastic Search Pingdom Pingdom Monitoring Dyn Dyn DNS Sentry Sentry Error Logging CloudAMQP CloudAMQP RabbitMQ Heroku Heroku PaaS Kabu Creative Kabu Creative UX & Design Fastly Fastly CDN DigiCert DigiCert EV Certificate Rackspace Rackspace Cloud Servers DreamHost DreamHost Log Hosting