~ubuntu-branches/ubuntu/precise/keystone/precise-security

« back to all changes in this revision

Viewing changes to keystone/common/logging.py

  • Committer: Package Import Robot
  • Author(s): Chuck Short
  • Date: 2012-03-09 12:26:12 UTC
  • mto: (25.1.1 precise-proposed)
  • mto: This revision was merged to the branch mainline in revision 21.
  • Revision ID: package-import@ubuntu.com-20120309122612-t4zqpaytkiptezsa
Tags: upstream-2012.1~rc1~20120308.2103
ImportĀ upstreamĀ versionĀ 2012.1~rc1~20120308.2103

Show diffs side-by-side

added added

removed removed

Lines of Context:
8
8
import logging
9
9
import logging.config
10
10
import pprint
 
11
import traceback
11
12
 
12
13
from logging.handlers import SysLogHandler
13
14
from logging.handlers import WatchedFileHandler
55
56
        logging.debug('')
56
57
        return rv
57
58
    return wrapper
 
59
 
 
60
 
 
61
def fail_gracefully(f):
 
62
    """Logs exceptions and aborts."""
 
63
    @functools.wraps(f)
 
64
    def wrapper(*args, **kw):
 
65
        try:
 
66
            return f(*args, **kw)
 
67
        except Exception as e:
 
68
            # tracebacks are kept in the debug log
 
69
            logging.debug(traceback.format_exc(e))
 
70
 
 
71
            # exception message is printed to all logs
 
72
            logging.critical(e)
 
73
 
 
74
            exit(1)
 
75
    return wrapper