Source

pythonhk / loggingcfg.py.sample

Full commit
import sys
import os.path as path

config = {'version': 1,
          'disable_existing_loggers': False,
          'loggers':
              {'root':
                   {'level': 'WARNING',
                    'handlers': ['rfile']},
               'pythonhk':
                   {'level': 'INFO',
                    'handlers': ['rfile'],
                    'propagate': False},
               'sqlalchemy':
                   {'level': 'WARNING',
                    'handlers': ['sa'],
                    'propagate': False},
               'sqlalchemy.engine':
                   {'level': 'WARNING',
                    'handlers': ['sa'],
                    'propagate': False},
               'sqlalchemy.dialects':
                   {'level': 'WARNING',
                    'handlers': ['sa'],
                    'propagate': False},
               'sqlalchemy.pool':
                   {'level': 'WARNING',
                    'handlers': ['sa'],
                    'propagate': False},
               'sqlalchemy.orm':
                   {'level': 'WARNING',
                    'handlers': ['sa'],
                    'propagate': False},
               'sqlalchemy.orm.attributes':
                   {'level': 'WARNING',
                    'handlers': ['sa'],
                    'propagate': False},
               'sqlalchemy.orm.mapper':
                   {'level': 'WARNING',
                    'handlers': ['sa'],
                    'propagate': False},
               'sqlalchemy.orm.unitofwork':
                   {'level': 'WARNING',
                    'handlers': ['sa'],
                    'propagate': False},
               'sqlalchemy.orm.strategies':
                   {'level': 'WARNING',
                    'handlers': ['sa'],
                    'propagate': False},
               'sqlalchemy.orm.sync':
                   {'level': 'WARNING',
                    'handlers': ['sa'],
                    'propagate': False},
               },
          'handlers':
              {'stdout':
                   {'class': 'logging.StreamHandler',
                    'formatter': 'debug',
                    'stream': sys.stdout},
               'stderr':
                   {'class': 'logging.StreamHandler',
                    'formatter': 'debug',
                    'stream': sys.stderr},
               'rfile':
                   {'class': 'logging.handlers.RotatingFileHandler',
                    'formatter': 'debug',
                    'filename': path.join(path.dirname(__file__), 'log/pythonhk.log'),
                    'maxBytes': 1048576,
                    'backupCount': 5,
                    'encoding': 'utf8'},
               'trfile':
                   {'class': 'logging.handlers.TimedRotatingFileHandler',
                    'formatter': 'error',
                    'filename': path.join(path.dirname(__file__), 'log/pythonhk.log'),
                    'when': 'midnight',
                    'backupCount': 60,
                    'encoding': 'utf8'},
               'sa':
                   {'class': 'logging.handlers.RotatingFileHandler',
                    'formatter': 'debug',
                    'filename': path.join(path.dirname(__file__), 'log/pythonhk.log'),
                    'maxBytes': 1048576,
                    'backupCount': 5,
                    'encoding': 'utf8'}
               },
          'formatters':
              {'debug':
                   {'format': '%(asctime)s [%(levelname)s] %(name)s Thread(id=%(thread)d, name="%(threadName)s") %(message)s'},
               'info':
                   {'format': '%(asctime)s [%(levelname)s] %(name)s %(message)s'},
               'error':
                   {'format': '%(asctime)s [%(levelname)s] %(name)s Thread(id=%(thread)d, name="%(threadName)s") %(module)s.%(funcName)s: line %(lineno)d %(message)s'}
               }
          }