This is a pre-production deployment of Warehouse, however changes made here WILL affect the production instance of PyPI.
Latest Version Dependencies status unknown Test status unknown Test coverage unknown
Project Description

pylogd

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

usage

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

logging

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', '127.0.0.1', 8126)
logger = logging.getLogger()
logger.setHandler(handler)

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='127.0.0.1', 8126)

stats

To use stats, create a stats handle:

from pylogd.stats import Logd
stats = Logd('127.0.0.1', 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.increment('my.counter')
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
stats.timer.start('my.timer')
do_some_timed_operation()
stats.timer.stop('my.timer')

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

# accumulate time done doing various similar tasks
stats.timer.start_accumulator('timers.mysql')
do_some_mysql_stuff()
stats.timer.stop_accumulator('timers.mysql')
non_mysql_things()
stats.timer.start_accumulator('timers.mysql')
do_some_more_mysql_stuff()
stats.timer.stop_accumulator('timers.mysql')

# send this timing information to logd
stats.timer.flush_accumulator('timers.mysql')

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

0.2

This version

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

Download Files

Download Files

TODO: Brief introduction on what you do with files - including link to relevant help section.

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 HPE HPE Development 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