当前位置: 首页>>代码示例>>Python>>正文


Python structlog.get_logger方法代码示例

本文整理汇总了Python中structlog.get_logger方法的典型用法代码示例。如果您正苦于以下问题:Python structlog.get_logger方法的具体用法?Python structlog.get_logger怎么用?Python structlog.get_logger使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在structlog的用法示例。


在下文中一共展示了structlog.get_logger方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: __config_logger__

# 需要导入模块: import structlog [as 别名]
# 或者: from structlog import get_logger [as 别名]
def __config_logger__(self):
        logging.basicConfig(
            level=logging.INFO, format=self.log_format, stream=sys.stdout,
        )

        structlog.configure(
            processors=[
                structlog.stdlib.filter_by_level,
                structlog.stdlib.PositionalArgumentsFormatter(),
                structlog.processors.StackInfoRenderer(),
                structlog.processors.format_exc_info,
                structlog.processors.JSONRenderer(),
            ],
            logger_factory=structlog.stdlib.LoggerFactory(),
            wrapper_class=structlog.stdlib.BoundLogger,
        )
        return structlog.get_logger("Startup") 
开发者ID:codeforboston,项目名称:GovLens,代码行数:19,代码来源:app.py

示例2: __init__

# 需要导入模块: import structlog [as 别名]
# 或者: from structlog import get_logger [as 别名]
def __init__(self, config, exchange_interface, notifier):
        """Initializes DefaultBehaviour class.

        Args:
            indicator_conf (dict): A dictionary of configuration for this analyzer.
            exchange_interface (ExchangeInterface): Instance of the ExchangeInterface class for
                making exchange queries.
            notifier (Notifier): Instance of the notifier class for informing a user when a
                threshold has been crossed.
        """

        self.logger = structlog.get_logger()
        self.indicator_conf = config.indicators
        self.informant_conf = config.informants
        self.crossover_conf = config.crossovers
        self.exchange_interface = exchange_interface
        self.strategy_analyzer = StrategyAnalyzer()
        self.notifier = notifier

        output_interface = Output()
        self.output = output_interface.dispatcher 
开发者ID:CryptoSignal,项目名称:crypto-signal,代码行数:23,代码来源:behaviour.py

示例3: main

# 需要导入模块: import structlog [as 别名]
# 或者: from structlog import get_logger [as 别名]
def main():
    """Initializes the application
    """
     # Load settings and create the config object
    config = Configuration()
    settings = config.settings

    # Set up logger
    logs.configure_logging(settings['log_level'], settings['log_mode'])
    logger = structlog.get_logger()

    # Configure and run configured behaviour.
    exchange_interface = ExchangeInterface(config.exchanges)
    notifier = Notifier(config.notifiers)

    behaviour = Behaviour(
        config,
        exchange_interface,
        notifier
    )

    while True:
        behaviour.run(settings['market_pairs'], settings['output_mode'])
        logger.info("Sleeping for %s seconds", settings['update_interval'])
        time.sleep(settings['update_interval']) 
开发者ID:CryptoSignal,项目名称:crypto-signal,代码行数:27,代码来源:app.py

示例4: __init__

# 需要导入模块: import structlog [as 别名]
# 或者: from structlog import get_logger [as 别名]
def __init__(self, exchange_config):
        """Initializes ExchangeInterface class

        Args:
            exchange_config (dict): A dictionary containing configuration for the exchanges.
        """

        self.logger = structlog.get_logger()
        self.exchanges = dict()

        # Loads the exchanges using ccxt.
        for exchange in exchange_config:
            if exchange_config[exchange]['required']['enabled']:
                new_exchange = getattr(ccxt, exchange)({
                    "enableRateLimit": True
                })

                # sets up api permissions for user if given
                if new_exchange:
                    self.exchanges[new_exchange.id] = new_exchange
                else:
                    self.logger.error("Unable to load exchange %s", new_exchange) 
开发者ID:CryptoSignal,项目名称:crypto-signal,代码行数:24,代码来源:exchange.py

示例5: shutdown

# 需要导入模块: import structlog [as 别名]
# 或者: from structlog import get_logger [as 别名]
def shutdown(*, loop=None):
    _logger = structlog.get_logger()
    global _shutdown
    if _shutdown:
        _logger.warning('Already shutting down')
        return

    _shutdown = True

    _logger.debug(
        'shutting down',
    )

    print_tasks()

    _logger.info('Shutdown complete') 
开发者ID:miracle2k,项目名称:k8s-snapshots,代码行数:18,代码来源:__main__.py

示例6: override_sanic_loggers

# 需要导入模块: import structlog [as 别名]
# 或者: from structlog import get_logger [as 别名]
def override_sanic_loggers():
    # Override Sanic loggers with structlog loggers. Unfortunately
    # there isn't a great way of doing this because the Sanic modules
    # already hold a reference to the logging.Logger at import load,
    # so we are stuck with just replacing those references in their
    # respective modules.
    root = structlog.get_logger('sanic.root')
    error = structlog.get_logger('sanic.error')

    app.error_logger = error
    app.logger = root
    asgi.logger = root
    handlers.logger = root
    request.logger = root
    request.error_logger = error
    server.logger = root 
开发者ID:vapor-ware,项目名称:synse-server,代码行数:18,代码来源:log.py

示例7: get_logger

# 需要导入模块: import structlog [as 别名]
# 或者: from structlog import get_logger [as 别名]
def get_logger(
    name=None,
    level=None,
    stream=DEFAULT_STREAM,
    clobber_root_handler=True,
    logger_factory=None,
    wrapper_class=None,
):
    """Configure and return a logger with structlog and stdlib."""
    _configure_logger(logger_factory=logger_factory, wrapper_class=wrapper_class)
    log = structlog.get_logger(name)
    root_logger = logging.root
    if log == root_logger:
        if not _has_streamhandler(root_logger, level=level, stream=stream):
            stream_handler = logging.StreamHandler(stream)
            stream_handler.setLevel(level)
            stream_handler.setFormatter(logging.Formatter(fmt=LOG_FORMAT))
            root_logger.addHandler(stream_handler)
        else:
            if clobber_root_handler:
                for handler in root_logger.handlers:
                    handler.setFormatter(logging.Formatter(fmt=LOG_FORMAT))
    if level:
        log.setLevel(level)
    return log 
开发者ID:rackerlabs,项目名称:fleece,代码行数:27,代码来源:log.py

示例8: __init__

# 需要导入模块: import structlog [as 别名]
# 或者: from structlog import get_logger [as 别名]
def __init__(self, app):

        permissions_cfg = app.config.get('RELENGAPI_PERMISSIONS', {})
        self.group_permissions = permissions_cfg.get('group-permissions', {})

        # verify that each specified permission exists
        for perm in set(itertools.chain(*self.group_permissions.values())):
            try:
                p[perm]
            except KeyError:
                raise RuntimeError(
                    "invalid permission in settings: %r" % (perm,))

        self.uri = permissions_cfg['uri']
        self.login_dn = permissions_cfg['login_dn']
        self.login_password = permissions_cfg['login_password']
        self.user_base = permissions_cfg['user_base']
        self.group_base = permissions_cfg['group_base']
        self.debug = permissions_cfg.get('debug')

        self.logger = structlog.get_logger()

        permissions_stale.connect_via(app)(self.on_permissions_stale) 
开发者ID:mozilla,项目名称:build-relengapi,代码行数:25,代码来源:ldap_groups.py

示例9: __init__

# 需要导入模块: import structlog [as 别名]
# 或者: from structlog import get_logger [as 别名]
def __init__(self, adapter, device_id):
        self.adapter = adapter
        self.adapter_agent = adapter.adapter_agent
        self.device_id = device_id
        self.log = structlog.get_logger(device_id=device_id)
        self.incoming_messages = DeferredQueue()
        self.event_messages = DeferredQueue()
        self.proxy_address = None
        self.tx_id = 0
        self.flow_map = dict()

        # Need to query ONU for number of supported uni ports
        # For now, temporarily set number of ports to 1 - port #2
        self.uni_ports = (1, 2, 3, 4, 5)
        self.flow_config_in_progress = False

        # Handle received ONU event messages
        reactor.callLater(0, self.handle_onu_events) 
开发者ID:opencord,项目名称:voltha,代码行数:20,代码来源:broadcom_onu.py

示例10: __init__

# 需要导入模块: import structlog [as 别名]
# 或者: from structlog import get_logger [as 别名]
def __init__(self, handler, name, port_no, ofp_port_no):
        self.log = structlog.get_logger(device_id=handler.device_id, port_no=port_no)
        self._enabled = False
        self._handler = handler
        self._name = name
        self.uni_id = platform.uni_id_from_uni_port(port_no)
        self._port = None
        self._port_number = port_no
        self._ofp_port_no = ofp_port_no         # Set at by creator (vENET create)
        self._logical_port_number = None        # Set at time of logical port creation
        self._entity_id = None                  # TODO: Use port number from UNI-G entity ID
        self._mac_bridge_port_num = 0

        self._admin_state = AdminState.ENABLED
        self._oper_status = OperStatus.ACTIVE
        # TODO Add state, stats, alarm reference, ...
        pass 
开发者ID:opencord,项目名称:voltha,代码行数:19,代码来源:uni_port.py

示例11: __init__

# 需要导入模块: import structlog [as 别名]
# 或者: from structlog import get_logger [as 别名]
def __init__(self, handler, port_no):
        self.log = structlog.get_logger(device_id=handler.device_id, port_no=port_no)

        self._enabled = False
        self._valid = True
        self._handler = handler
        self._deferred = None
        self._port = None
        self._port_number = port_no
        self._entity_id = None                  # ANI entity ID
        self._next_entity_id = PonPort.MIN_GEM_ENTITY_ID

        self._admin_state = AdminState.ENABLED
        self._oper_status = OperStatus.ACTIVE

        self._gem_ports = {}                           # gem-id -> GemPort
        self._tconts = {}                              # alloc-id -> TCont

        # OMCI resources
        # TODO: These could be dynamically chosen (can be most any value)
        self.ieee_mapper_service_profile_entity_id = 0x100
        self.mac_bridge_port_ani_entity_id = 0x100 
开发者ID:opencord,项目名称:voltha,代码行数:24,代码来源:pon_port.py

示例12: __init__

# 需要导入模块: import structlog [as 别名]
# 或者: from structlog import get_logger [as 别名]
def __init__(self, adapter, device_id):
        self.adapter = adapter
        self.adapter_agent = adapter.adapter_agent
        self.device_id = device_id
        self.log = structlog.get_logger(device_id=device_id)
        #self.incoming_messages = Queue.Queue()
        self.incoming_messages = DeferredQueue()
        self.event_messages = Queue.Queue()
        self.proxy_address = None
        self.tx_id = 0
        self.trangen = sequence_generator(1)
        self.port_id = None
        self.alloc_id = None
        self.cvlan_id = None
        self.subsvlan_id = None
        self.bandwidth = None
        self.flows_lock = 0
        self.flows = None
        self.policy_id = None
        self.flow_queue = DeferredQueue() 
开发者ID:opencord,项目名称:voltha,代码行数:22,代码来源:tlgs_onu.py

示例13: __init__

# 需要导入模块: import structlog [as 别名]
# 或者: from structlog import get_logger [as 别名]
def __init__(self, adapter, device_id):
        self.adapter = adapter
        self.adapter_agent = adapter.adapter_agent
        self.device_id = device_id
        self.log = structlog.get_logger(device_id=device_id)
        self.channel = None
        self.io_port = None
        self.logical_device_id = None
        self.nni_port = None
        self.ofp_port_no = None
        self.interface = registry('main').get_args().interface
        self.ponsim_comm = registry('main').get_args().ponsim_comm
        self.pm_metrics = None
        self.alarms = None
        self.frames = None
        self.ctag_map = {} 
开发者ID:opencord,项目名称:voltha,代码行数:18,代码来源:ponsim_olt.py

示例14: __init__

# 需要导入模块: import structlog [as 别名]
# 或者: from structlog import get_logger [as 别名]
def __init__(self, handler, name, uni_id, port_no, ofp_port_no,
                 type=UniType.PPTP):
        self.log = structlog.get_logger(device_id=handler.device_id,
                                        port_no=port_no)
        self._enabled = False
        self._handler = handler
        self._name = name
        self._port = None
        self._port_number = port_no
        self._ofp_port_no = ofp_port_no
        self._logical_port_number = None
        self._entity_id = None
        self._mac_bridge_port_num = 0
        self._type = type
        self._uni_id = uni_id

        self._admin_state = AdminState.ENABLED
        self._oper_status = OperStatus.ACTIVE 
开发者ID:opencord,项目名称:voltha,代码行数:20,代码来源:uni_port.py

示例15: __init__

# 需要导入模块: import structlog [as 别名]
# 或者: from structlog import get_logger [as 别名]
def __init__(self, handler, port_no):
        self.log = structlog.get_logger(device_id=handler.device_id, port_no=port_no)
        self.log.debug('function-entry')

        self._enabled = False
        self._valid = True
        self._handler = handler
        self._deferred = None
        self._port = None
        self._port_number = port_no
        self._next_entity_id = PonPort.MIN_GEM_ENTITY_ID

        self._admin_state = AdminState.ENABLED
        self._oper_status = OperStatus.ACTIVE

        self._gem_ports = {}                           # gem-id -> GemPort
        self._tconts = {}                              # alloc-id -> TCont

        self.ieee_mapper_service_profile_entity_id = 0x8001
        self.mac_bridge_port_ani_entity_id = 0x2102  # TODO: can we just use the entity id from the anis list? 
开发者ID:opencord,项目名称:voltha,代码行数:22,代码来源:pon_port.py


注:本文中的structlog.get_logger方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。