}, { "name": 'log_date_format', "default": '%Y-%m-%d %H:%M:%S', "help": 'time format of log', "type": str, }, { "name": 'logfile_mode', "default": '0644', "help": 'Default file mode used when creating log files', "type": str, }, ] options = get_options(service_opts, 'services') # our new audit level # NOTE(jkoelker) Since we synthesized an audit level, make the logging # module aware of it so it acts like other levels. logging.AUDIT = logging.INFO + 1 logging.addLevelName(logging.AUDIT, 'AUDIT') try: NullHandler = logging.NullHandler except AttributeError: # NOTE(jkoelker) NullHandler added in Python 2.7 class NullHandler(logging.Handler): def handle(self, record): pass
#encoding=utf-8 import time from order_check.options import get_options from order_check.plugins.manageresource import OrderBase, PostData import order_check.log as logging from order_check.utils import get_now_time options = get_options() LOG = logging.getLogger(__name__) class Routers(OrderBase): def __init__(self, data, method, resource_type, token): """ data: the request data(get from redis types dict) """ super(Routers, self).__init__() self.data = data # the router id is `resource_id` self.resource_type = resource_type self.method = method self.token = token self.user_data = self.user_info(token=token) if self.method == "POST" or self.method == "PUT": try: self.base_data.resource_id = self.data.get("router").get("id") self.ip_address = data.get("router"). \ get('external_gateway_info'). \ get("external_fixed_ips")[0]. \ get("ip_address")
from order_check.options import get_options import order_check.log as logging auth_opts = [{ "name": "cached_backend", "default": 'redis://127.0.0.1:6379/0', "help": 'cached backend uri', "type": str, }, { "name": 'cache_timeout', "default": '3600', "help": 'cache timeout seconds', "type": str, }] options = get_options(auth_opts, 'cache') LOG = logging.getLogger(__name__) class Backend(object): def __init__(self): cached_backend = options.cached_backend _conn = cached_backend.split("//")[1] if '@' in _conn: passwd, host_port = _conn.split('@') else: passwd = None host_port = _conn if passwd: passwd = passwd[1:] host, db_p = host_port.split(':')