Skip to main content

Pyramid Sawing

https://travis-ci.org/Connexions/pyramid_sawing.svg https://badge.fury.io/py/pyramid_sawing.svg

A Pyramid framework plugin for configurating logging via YAML. This uses the Python standard-library’s logging (initialized using logging.config.dictConfig).

Usage

Include the package in your project, either by adding to the INI configuration:

pyramid.includes = pyramid_sawing
pyramid_sawing.file = my-logging-config.yaml

Or declarative via the configuration object:

config.include('pyramid_sawing')
assert 'pyramid_sawing.file' in config.registry.settings

You’ll be required to specify a logging configuration file at pyramid_sawing.file, which points to the file that contains your YAML logging configuration.

YAML Configuration

This configuration follows the standard-library’s logging.config dictionary schema

An example configuration might look like this:

###
# logging configuration
###
version: 1

formatters:
  generic:
    format    : '%(asctime)s %(levelname)-5.5s [%(name)s][%(threadName)s] %(message)s'
  papertrail:
    format    : '%(asctime)s %(hostname)s my_project %(message)s'
    datefmt   : '%Y-%m-%dT%H:%M:%S'
filters:
  context:
    ()        : pyramid_sawing.filters.ContextFilter
handlers:
  console:
    class     : logging.StreamHandler
    level     : NOTSET
    formatter : generic
    stream    : 'ext://sys.stdout'
  syslog:
    class     : logging.handlers.SysLogHandler
    level     : DEBUG
    formatter : papertrail
    filters   : [context]
    address   : ['<host>.papertrailapp.com', 11111]
loggers:
  my_project:
    level     : INFO
    handlers  : [console, syslog]
    propagate : 0
root:
  level       : NOTSET
  handlers    : []

A typical gotcha in configuring this is to forget the ‘version’. Please make sure you include version: 1 in your configuration.

Additional Features

Transit Logging

This resembles the functionality you would find in pyramid_translogger except that this implementation is more configurable.

To enable this feature, add the following line to your configuraton/settings.

pyramid_sawing.transit_logging.enabled? = yes
# Optional...
# The default logger_name is `transit_logger`
pyramid_sawing.transit_logging.logger_name = lumberjack

A template for configuring the transit logger would be something like:

formatters:
  apache_style:
    # filters : [environ]
    format    : '%(REMOTE_ADDR)s - %(REMOTE_USER)s [%(asctime)s] "%(REQUEST_METHOD)s %(REQUEST_URI)s %(HTTP_VERSION)s" %(status)s %(bytes)s "%(HTTP_REFERER)s" "%(HTTP_USER_AGENT)s"'
    datefmt   : '%d/%b/%Y:%H:%M:%S'
filters:
  environ:
    ()        : pyramid_sawing.filters.EnvironFilter
handlers:
  console:
    class     : logging.StreamHandler
    formatter : apache_style
    filters   : [environ]
    stream    : 'ext://sys.stdout'
loggers:
  transit_logger:
    handlers  : [console]
    propagate : 0

This should give you the exact same output as pyramid_translogger.

License

This software is subject to the provisions of the GNU Affero General Public License Version 3.0 (AGPL). See LICENSE.txt for details. Copyright (c) 2015 Rice University

Change Log

1.1.1

  • Fix the transit logging tween by returning the response, which caused secondary tweens and event subscribers to fail. [pumazi]

1.1.0

  • Add a transit (request) logging feature that mimics functionality found in pyramid_translogger. [pumazi]

1.0.0

  • Add a logging filter that allows for %(hostname)s be be used within log lines. [pumazi]

  • Logging from a YAML file. [pumazi]

Download files

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

Source Distributions

pyramid_sawing-1.1.1.zip (25.4 kB view details)

Uploaded Source

pyramid_sawing-1.1.1.tar.gz (18.2 kB view details)

Uploaded Source

pyramid_sawing-1.1.1.tar.bz2 (17.0 kB view details)

Uploaded Source

File details

Details for the file pyramid_sawing-1.1.1.zip.

File metadata

  • Download URL: pyramid_sawing-1.1.1.zip
  • Upload date:
  • Size: 25.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for pyramid_sawing-1.1.1.zip
Algorithm Hash digest
SHA256 c2d9f7007fac4e5afc69af82c80fe90a1f7ebf86e4aab87feddb614f7613fddb
MD5 22369e483a934c1cdf6728ca4e03412e
BLAKE2b-256 bbbcf88e1f7400a0544110aab1894e6bee1e466cefa22879c1d59404f693a425

See more details on using hashes here.

File details

Details for the file pyramid_sawing-1.1.1.tar.gz.

File metadata

File hashes

Hashes for pyramid_sawing-1.1.1.tar.gz
Algorithm Hash digest
SHA256 20c05611f31009177a1a7f415b1ad5b0c234445018520b63bdaa2338ad5cde89
MD5 34f13e348037b537bd2f775936e0762b
BLAKE2b-256 f5e1925a54ff9bc57f7ceba462bd6d02b9388f38cf67c3f1eb3895bf0aca1f20

See more details on using hashes here.

File details

Details for the file pyramid_sawing-1.1.1.tar.bz2.

File metadata

File hashes

Hashes for pyramid_sawing-1.1.1.tar.bz2
Algorithm Hash digest
SHA256 57287fffa8b438fcb864418a4335074b91d32fbdcb1fa82868e60747981dc7b8
MD5 3cbe62b9d2eef9d490f2802aaaaab9fe
BLAKE2b-256 4c1f06cd1e8b127606ca8af7bde2c3ea4c982006b1e66cd13431000c0a980de7

See more details on using hashes here.

Release history Release notifications | RSS feed

1.1.3

2 files

1.1.2

3 files

This release

1.1.1 This release

3 files

1.1.0

3 files

1.0.0

3 files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page