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

Introduction

Do you find yourself repeating the same statements over and over again to get your logging configured? I did.

bp.logging eases logging setup in that these kind of statements are reduced to a bare minimum. It does so by providing a getLogger function which returns the same as Python’s standard library function with the same name: an instance of the Logger class (a.k.a. a logger object). The difference to the Python Library’s getLogger are the arguments that can be passed and the default configuration of the returned logger object.

bp.logging might not be useful for anyone besides myself, as default logging is configured for my very own habits and you won’t gain much from using it instead of Python’s standard logging facilities if your’s are quite different. Maybe one day bp.logging will be extended and much more generic and/or configurable, but that day might be long after the universe has collapsed.

Usage

from bp.logging import *

logger = getLogger(name, console_threshold=None, logfile_threshold=None, logfile_path=None, console_format="%(levelname)s: %(name)s - %(message)s", logfile_format="%(asctime)s - %(levelname)s: %(name)s - %(message)s")

logger.critical("critical message")

logger.error("error message")

logger.warning("warning message")

logger.info("info message")

logger.debug("debug message")

Examples

debugging to console

logger = getLogger("my logger", console_threshold=debug)

or

logger = getLogger("my logger", debug)

warnings to file

logger = getLogger("my logger", logfile_path="/var/log/my.log", logfile_threshold=warning)

infos to console, errors to file

logger = getLogger("my logger", console_threshold=info, logfile_path="/var/log/my.log", logfile_threshold=error)

or

logger = getLogger("my logger", info, error, "/var/log/my.log")

Changelog

0.2

  • Fixed bug when console and logfile thresholds are different. Now the logger’s level is set to the lowest level of it’s handlers.

0.1

  • Initial release

LICENSE

Copyright (c) 2011, disko@binary-punks.com

All rights reserved.

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

  • Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
  • Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
  • Neither the name of the binary punks nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS “AS IS” AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

Release History

Release History

0.2.1

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

0.2

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

0.2-dev

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

0.1

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

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
bp.logging-0.2.1.zip (15.0 kB) Copy SHA256 Checksum SHA256 Source Feb 5, 2011

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