Пример #1
0
def _configure_logging():
    logging_unterpolation.patch_logging()
    fname = os.path.join(get_config_root(), 'logging.cfg')
    if os.path.exists(fname):
        logging.config.fileConfig(fname, disable_existing_loggers=True)
    else:
        # ConfigObj doesn't support interpolation escaping, so we manually work around it here
        formatters = config['formatters'].dict()
        for formatter in formatters.values():
            formatter['format'] = formatter['format'].replace('$$', '%')
            formatter['datefmt'] = formatter['datefmt'].replace('$$',
                                                                '%') or None
        formatters['indent_multiline'] = {
            '()': IndentMultilinesLogFormatter,
            'format': formatters['default']['format']
        }
        logging.config.dictConfig({
            'version': 1,
            'root': {
                'level': config['loggers']['root'],
                'handlers': config['handlers'].dict().keys()
            },
            'loggers': {
                name: {
                    'level': level
                }
                for name, level in config['loggers'].items() if name != 'root'
            },
            'handlers': config['handlers'].dict(),
            'formatters': formatters
        })
Пример #2
0
def _configure_logging():
    logging_unterpolation.patch_logging()
    fname='/etc/sideboard/logging.cfg'
    if os.path.exists(fname):
        logging.config.fileConfig(fname, disable_existing_loggers=True)
    else:
        format_str = '%(asctime)s [%(levelname)s] %(name)s: %(message)s'
        logging.config.dictConfig({
        'version': 1,
        'root': {
            'level': config['loggers']['root'],
            'handlers': config['handlers'].dict().keys()
        },
        'loggers': {
            name: {'level': level}
            for name, level in config['loggers'].items() if name != 'root'
        },
        'handlers': config['handlers'].dict(),
        'formatters': {
            'default': {
                'format': format_str,
            },
            'indent_multiline': {
                '()': IndentMultilinesLogFormatter,
                'format': format_str,
            },
        }
    })
Пример #3
0
def _configure_logging():
    logging_unterpolation.patch_logging()
    fname = os.path.join(get_config_root(), 'logging.cfg')
    if os.path.exists(fname):
        logging.config.fileConfig(fname, disable_existing_loggers=True)
    else:
        # ConfigObj doesn't support interpolation escaping, so we manually work around it here
        formatters = config['formatters'].dict()
        for formatter in formatters.values():
            formatter['format'] = formatter['format'].replace('$$', '%')
            formatter['datefmt'] = formatter['datefmt'].replace('$$', '%') or None
        formatters['indent_multiline'] = {
            '()': IndentMultilinesLogFormatter,
            'format': formatters['default']['format']
        }
        logging.config.dictConfig({
            'version': 1,
            'root': {
                'level': config['loggers']['root'],
                'handlers': config['handlers'].dict().keys()
            },
            'loggers': {
                name: {'level': level}
                for name, level in config['loggers'].items() if name != 'root'
            },
            'handlers': config['handlers'].dict(),
            'formatters': formatters
        })
Пример #4
0
    def setUpClass(cls):
        """
        set up the patched logger
        """

        import logging
        from logging_unterpolation import patch_logging
        patch_logging()

        super(TestSingleFileImportCase, cls).setUpClass()
Пример #5
0
from __future__ import absolute_import

from logging_unterpolation import patch_logging
patch_logging()

import logging
import inspect

class AutoLogger(object):
    """
    A logger proxy object, with all of the methods and attributes of C{Logger}.

    When an attribute (e.g., "debug") is requested, inspects the stack for the
    calling module's name, and passes that name to C{logging.getLogger}.

    What this means is that you can instantiate an C{AutoLogger} anywhere, and
    when you call it, the log entry shows the module where you called it, not
    where it was created.

    C{AutoLogger} also inspects the local variables where it is called, looking
    for C{self}. If C{self} exists, its classname is added to the module name.
    """
    def __getattr__(self, name):
        if 'self' in inspect.currentframe(1).f_locals:
            other = inspect.currentframe(1).f_locals['self']
            caller_name = '%s.%s'%(other.__class__.__module__,
                                   other.__class__.__name__)
        else:
            caller_name = inspect.currentframe(1).f_globals['__name__']
        logger = logging.getLogger(caller_name)
        return getattr(logger, name)
Пример #6
0
from uber.constants import *
from uber import constants

from django import template
from django.db import connection
from django.db.models import base
from django.dispatch import receiver
from django.forms.models import model_to_dict
from django.utils.safestring import SafeString
from django.db.models.signals import pre_save, post_save, pre_delete
from django.template import loader, Context, Variable, TemplateSyntaxError
from django.db.models import Q, Avg, Sum, Count, Model, ForeignKey, OneToOneField, BooleanField, CharField, TextField, IntegerField, FloatField, DateField, DateTimeField, CommaSeparatedIntegerField

import stripe
stripe.api_key = STRIPE_SECRET_KEY

import logging_unterpolation
logging_unterpolation.patch_logging()

from uber.utils import *
from uber.decorators import *
from uber.models import *
from uber.badge_funcs import *
from uber import model_checks
from uber import custom_tags
from uber.server import *

# kludgy hack because I love "from <module> import *" way too much
for _module in ['utils', 'models', 'custom_tags', 'decorators']:
    __import__('uber.' + _module, fromlist=['os']).__dict__.update(globals())