import inspect from environments import Environment from inspection import Inspection # This is the one thing that is provided de-facto with every application # whether you like it or not. from twitter.common import options class AppException(Exception): pass options.add( '--env', '--environment', action='callback', callback=Environment._option_parser, default='DEVELOPMENT', metavar='ENV', dest='twitter_common_app_environment', help="The environment in which to run this Python application. " "Known environments: %s [default: %%default]" % ' '.join(Environment.names())) options.add( '--app_debug', action='store_true', default=False, dest='twitter_common_app_debug', help="Print extra debugging information during application initialization.") _APP_REGISTRY = {} _APP_NAME = None _APP_INITIALIZED = False
from inspection import Inspection # This is the one thing that is provided de-facto with every application # whether you like it or not. from twitter.common import options class AppException(Exception): pass options.add('--env', '--environment', action='callback', callback=Environment._option_parser, default='DEVELOPMENT', metavar='ENV', dest='twitter_common_app_environment', help="The environment in which to run this Python application. " "Known environments: %s [default: %%default]" % ' '.join(Environment.names())) options.add( '--app_debug', action='store_true', default=False, dest='twitter_common_app_debug', help="Print extra debugging information during application initialization." ) _APP_REGISTRY = {} _APP_NAME = None
def _stdout_options_callback(option, opt, value, parser): try: LogOptions.set_stdout_log_level(value) except LogOptionsException, e: raise optparse.OptionValueError('Failed to parse option: %s' % e) _LOGGING_HELP = \ """The level at which to log to %%s [default: %%%%default]. Takes either LEVEL or scheme:LEVEL, where LEVEL is one of %s and scheme is one of %s. """ % (repr(LogOptions._LOG_LEVELS.keys()), repr(LogOptions._LOG_SCHEMES)) options.add('--log_to_stdout', callback=LogOptions._stdout_options_callback, default='NONE', type='string', action='callback', metavar='[scheme:]LEVEL', dest='twitter_common_log_stdout_log_level', help=_LOGGING_HELP % 'stdout') options.add('--log_to_disk', callback=LogOptions._disk_options_callback, default='INFO', type='string', action='callback', metavar='[scheme:]LEVEL', dest='twitter_common_log_disk_log_level', help=_LOGGING_HELP % 'disk') options.add('--log_dir', type='string',
""" LogOptions._LOG_DIR = dir @staticmethod def log_dir(): """ Get the current directory into which logs will be written. """ if LogOptions._LOG_DIR is None: LogOptions._LOG_DIR = options.values().glog_log_dir return LogOptions._LOG_DIR options.add('--log_to_stdout', type='choice', choices=LogOptions._LOG_LEVELS.keys(), default='NONE', metavar='LEVEL', dest='glog_log_to_stdout', help="The level at which to log to stdout [default: %default], " "can be one of: DEBUG INFO WARN ERROR FATAL NONE") options.add('--log_to_disk', type='choice', choices=LogOptions._LOG_LEVELS.keys(), default='INFO', metavar='LEVEL', dest='glog_log_to_disk', help="The level at which to log to disk [default: %default], " "can be one of: DEBUG INFO WARN ERROR FATAL NONE") options.add('--log_dir', type='string',