Package: pyramid-sawing
Pyramid SawingA Pyramid framework plugin for configurating logging
viaYAML.
This uses the Python standard-library’s logging
(initialized usinglogging.config.dictConfig).Table of ContentsPyramid SawingUsageYAML ConfigurationAdditional FeaturesLicenseChange Log1.1.31.1.21.1.11.1.01.0.0UsageInclude the package in your project, either by adding to the INI configuration:pyramid.includes = pyramid_sawing
pyramid_sawing.file = my-logging-config.yamlOr declarative via the configuration object:config.include('pyramid_sawing')
assert 'pyramid_sawing.file' in config.registry.settingsYou’ll be required to specify a logging configuration file
atpyramid_sawing.file, which points to the file that contains your
YAML logging configuration.YAML ConfigurationThis configuration follows the standard-library’slogging.config dictionary schemaAn 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 typicalgotchain configuring this is to forget the ‘version’. Please
make sure you includeversion: 1in your configuration.Additional FeaturesTransit LoggingThis resembles the functionality you would find inpyramid_transloggerexcept 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 = lumberjackA 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 : 0This should give you the exact same output aspyramid_translogger.LicenseThis 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 UniversityChange Log1.1.3Adjust the transit logging tween to set and return the response attribute
of the request object.Fix tests for Python3 compatiblity.1.1.2Fix the transit logging tween to return the response coming from
the handler rather than the one attached to the request object. [pumazi]1.1.1Fix the transit logging tween by returning the response,
which caused secondary tweens and event subscribers to fail. [pumazi]1.1.0Add a transit (request) logging feature that mimics functionality
found inpyramid_translogger. [pumazi]1.0.0Add a logging filter that allows for%(hostname)sbe be used
within log lines. [pumazi]Logging from a YAML file. [pumazi]