Skip to main content

Scribe logger proxy layer that works with the python standard logging module

Project description

ScribeHandler is a simple proxy layer that works with the python standard
logging module (http://docs.python.org/library/logging.html). ScribeHandler
acts a a handler object that gets added to a logger in the standard way.

Important bits:

When instantiating the handler, you will want to specify the connection
setting to scribed. The following keyword arguments are reconized (and
defaults):

Argument Default
---------------------------
host 172.0.0.1
port 1463
category %(hostname)s-%(loggername)s
transport ScribeHandler.FRAMED
uri None

- Host and port, should be obvious

- If transport is ScribeHandler.FRAMED, then
thrift.transport.TTransport.TFramedTransport() is used.
- If transport is ScribeHandler.BUFFERED, then
thrift.transport.TTransport.TBufferedTransport() is used.
- If transport is ScribeHandler.HTTP then
thrift.transport.THttpClient.THttpClient() is used and uri MUST NOT be
None
- If transport is None then you can assign any acceptable Thrift/Scribe
transport via

ScirbeHandler.transport = <transport>

where <transport> is a valid Scibe/Thrift transport (this is an attempt at
future proofing).

- category is translated into the category parameter to scribe.LogEntry()
object. It should be a standard format string using mapping keys.
The following are the reconized mapping keys:

Key Name Source
----------------------
module logging.LogRecord.module
levelname logging.LogRecord.levelname
loggername logging.LogRecord.name
processname logging.LogRecord.processName
hostname socket.gethostname()


Here's a simple example of how to use it:

import logging
import ScribeHandler
mylogger = logging.getLogger('ScribeLogger')
mylogger.setLevel(logging.DEBUG)
handler = ScribeHandler.ScribeHandler(category='%(hostname)s-%(levelname)s')
mylogger.addHandler(handler)

mylogger.debug('stuff happens')

Project details


Download files

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

Source Distribution

ScribeHandler-0.02.tar.gz (9.2 kB view details)

Uploaded Source

File details

Details for the file ScribeHandler-0.02.tar.gz.

File metadata

  • Download URL: ScribeHandler-0.02.tar.gz
  • Upload date:
  • Size: 9.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for ScribeHandler-0.02.tar.gz
Algorithm Hash digest
SHA256 9c2de326a650c97cf4ad8c8a3654ac5a142c8ace6bac6e2d038b0d8056c53e13
MD5 9401696ec8243b347eedf7f7b24ca901
BLAKE2b-256 e8c3e7de16605906e7f406e437c6ad5aec2937b180edb6f00b798c5f0183d5ea

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page