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


Python logbook.Logger方法代码示例

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


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

示例1: set_logger

# 需要导入模块: import logbook [as 别名]
# 或者: from logbook import Logger [as 别名]
def set_logger(self, level=None, task=None):
        """
        Sets logbook logger.

        Args:
            level:  logbook.level, int
            task:   task id, int

        """
        if task is not None:
            self.task = task

        if level is not None:
            for stream in self.data.values():
                stream.log = Logger('{}_{}'.format(stream.name, stream.task), level=level)

            self.log = Logger('{}_{}'.format(self.name, self.task), level=level) 
开发者ID:Kismuz,项目名称:btgym,代码行数:19,代码来源:multi.py

示例2: define_logger

# 需要导入模块: import logbook [as 别名]
# 或者: from logbook import Logger [as 别名]
def define_logger(code: str) -> str:
    """
    quantopian has a default logger called "log"
    we add a logger that prints to the console which will make sure all log
    usage will stay valid.
    """

    logger = """

from logbook import Logger, StreamHandler
import sys
StreamHandler(sys.stdout).push_application()
log = Logger(__name__)

"""
    return logger + code 
开发者ID:alpacahq,项目名称:pylivetrader,代码行数:18,代码来源:migration_tool.py

示例3: setup_logging

# 需要导入模块: import logbook [as 别名]
# 或者: from logbook import Logger [as 别名]
def setup_logging(self):

        from logbook.compat import redirect_logging
        from logbook import INFO, Logger

        redirect_logging()
        self.components['log'].handler.level = INFO
        self.components['log'].handler.push_application()

        self._logger = Logger(self.name)

        def handle_exception(exc_type, exc_value, exc_traceback):

            if issubclass(exc_type, KeyboardInterrupt):
                sys.__excepthook__(exc_type, exc_value, exc_traceback)
                return

            self._logger.error("Uncaught exception occurred",
                               exc_info=(exc_type, exc_value, exc_traceback))

        sys.excepthook = handle_exception 
开发者ID:CadQuery,项目名称:CQ-editor,代码行数:23,代码来源:main_window.py

示例4: analyze

# 需要导入模块: import logbook [as 别名]
# 或者: from logbook import Logger [as 别名]
def analyze(context=None, results=None):
    import matplotlib.pyplot as plt
    import logbook
    logbook.StderrHandler().push_application()
    log = logbook.Logger('Algorithm')

    fig = plt.figure()
    ax1 = fig.add_subplot(211)

    results.algorithm_period_return.plot(ax=ax1,color='blue',legend=u'策略收益')
    ax1.set_ylabel(u'收益')
    results.benchmark_period_return.plot(ax=ax1,color='red',legend=u'基准收益')

    plt.show()

# capital_base is the base value of capital
# 
开发者ID:zhanghan1990,项目名称:zipline-chinese,代码行数:19,代码来源:doubleMA.py

示例5: get_logger

# 需要导入模块: import logbook [as 别名]
# 或者: from logbook import Logger [as 别名]
def get_logger(logger_name=None):
    """
    The common pattern for using this method is to create a logger instance in your class constructor:
      >>> self._logger = get_logger(__name__)

    Then use that logger instance anywhere you'd place a print statement. Provide extra arguments directly to the
    logger method instead of using string.format:
      >>> self._logger.warning('The file {} was not found.', filename)

    Do not use print() in the app code -- we should be using a logger instead.
        - This gives us much more granular and semantic control over what the system is outputting (via the log level).
        - It ensures multiple threads will not be writing to stdout at the same time.
        - The work of doing string formatting is only done if the message is actually going to be output.

    :param logger_name: The name of the logger -- in most cases this just should be the module name (__name__)
    :type logger_name: str
    :return: The logger instance
    :rtype: logbook.Logger
    """
    name_without_package = logger_name.rsplit('.', 1)[-1]  # e.g., converts "project_type.git" to "git"
    return Logger(name_without_package) 
开发者ID:box,项目名称:ClusterRunner,代码行数:23,代码来源:log.py

示例6: get_logger

# 需要导入模块: import logbook [as 别名]
# 或者: from logbook import Logger [as 别名]
def get_logger(name=None, level=logbook.NOTSET):
    """
    Return a :class:`logbook.Logger`.

    Arguments:
        - `name`: The name of a specific sub-logger.
    """
    base_name = 'threema.gateway'
    name = base_name if name is None else '.'.join((base_name, name))

    # Create new logger and add to group
    logger = logbook.Logger(name=name, level=level)
    _logger_group.add_logger(logger)
    return logger


# TODO: Raises 
开发者ID:lgrahl,项目名称:threema-msgapi-sdk-python,代码行数:19,代码来源:util.py

示例7: store_creds

# 需要导入模块: import logbook [as 别名]
# 或者: from logbook import Logger [as 别名]
def store_creds(email, password, creds_file):
    """
    Store login credentials
    Args:
        email: the LinkedIn login email
        password: the LinkedIn login password
        creds_file: the credentials file to store the login credentials

    Returns:
        None
    """
    log = Logger()
    log.warn(
        f"It is highly NOT recommended to keep your login credentials, "
        f"you can always remove the file {CREDENTIALS_FILE} to remove them"
    )

    make_dir(os.path.expanduser(f"~/.{PACKAGE_NAME}"))
    credentials = {"email": email, "password": password}

    with open(creds_file, "w") as f:
        json.dump(credentials, f) 
开发者ID:zeshuaro,项目名称:LinkedRW,代码行数:24,代码来源:main.py

示例8: get_startup_log

# 需要导入模块: import logbook [as 别名]
# 或者: from logbook import Logger [as 别名]
def get_startup_log():
        return logbook.Logger("App") 
开发者ID:mikeckennedy,项目名称:python-for-entrepreneurs-course-demos,代码行数:4,代码来源:log_service.py

示例9: __init__

# 需要导入模块: import logbook [as 别名]
# 或者: from logbook import Logger [as 别名]
def __init__(self, request):
        self.request = request
        self.build_cache_id = static_cache.build_cache_id

        layout_render = pyramid.renderers.get_renderer('blue_yellow_app:templates/shared/_layout.pt')
        impl = layout_render.implementation()
        self.layout = impl.macros['layout']

        log_name = 'Ctrls/' + type(self).__name__.replace("Controller", "")
        self.log = logbook.Logger(log_name) 
开发者ID:mikeckennedy,项目名称:python-for-entrepreneurs-course-demos,代码行数:12,代码来源:base_controller.py

示例10: __init__

# 需要导入模块: import logbook [as 别名]
# 或者: from logbook import Logger [as 别名]
def __init__(self, loggerName):
        StreamHandler(sys.stdout).push_application()
        self.logger = lg(loggerName) 
开发者ID:autoai-org,项目名称:CVTron,代码行数:5,代码来源:Logger.py

示例11: set_logger

# 需要导入模块: import logbook [as 别名]
# 或者: from logbook import Logger [as 别名]
def set_logger(self, level=None, task=None):
        """
        Sets logbook logger.

        Args:
            level:  logbook.level, int
            task:   task id, int

        """
        if task is not None:
            self.task = task

        if level is not None:
            self.log = Logger('{}_{}'.format(self.name, self.task), level=level) 
开发者ID:Kismuz,项目名称:btgym,代码行数:16,代码来源:base.py

示例12: __init__

# 需要导入模块: import logbook [as 别名]
# 或者: from logbook import Logger [as 别名]
def __init__(self, *args, **kwargs):
        self.plug = (np.random.rand(100, 200, 3) * 255).astype(dtype=np.uint8)
        self.params = {'rendering': 'disabled'}
        self.render_modes = []
        # self.log_level = WARNING
        # StreamHandler(sys.stdout).push_application()
        # self.log = Logger('BTgymRenderer', level=self.log_level) 
开发者ID:Kismuz,项目名称:btgym,代码行数:9,代码来源:renderer.py

示例13: __init__

# 需要导入模块: import logbook [as 别名]
# 或者: from logbook import Logger [as 别名]
def __init__(self, history_size, max_sample_size, priority_sample_size, log_level=WARNING,
                 rollout_provider=None, task=-1, reward_threshold=0.1, use_priority_sampling=False):
        """

        Args:
            history_size:           number of experiences stored;
            max_sample_size:        maximum allowed sample size (e.g. off-policy rollout length);
            priority_sample_size:   sample size of priority_sample() method
            log_level:              int, logbook.level;
            rollout_provider:       callable returning list of Rollouts NOT USED
            task:                   parent worker id;
            reward_threshold:       if |experience.reward| > reward_threshold: experience is saved as 'prioritized';
        """
        self._history_size = history_size
        self._frames = deque(maxlen=history_size)
        self.reward_threshold = reward_threshold
        self.max_sample_size = int(max_sample_size)
        self.priority_sample_size = int(priority_sample_size)
        self.rollout_provider = rollout_provider
        self.task = task
        self.log_level = log_level
        StreamHandler(sys.stdout).push_application()
        self.log = Logger('ReplayMemory_{}'.format(self.task), level=self.log_level)
        self.use_priority_sampling = use_priority_sampling
        # Indices for non-priority frames:
        self._zero_reward_indices = deque()
        # Indices for priority frames:
        self._non_zero_reward_indices = deque()
        self._top_frame_index = 0

        if use_priority_sampling:
            self.sample_priority = self._sample_priority

        else:
            self.sample_priority = self._sample_dummy 
开发者ID:Kismuz,项目名称:btgym,代码行数:37,代码来源:memory.py

示例14: __init__

# 需要导入模块: import logbook [as 别名]
# 或者: from logbook import Logger [as 别名]
def __init__(self, *bots, workers=2):
        # Only frozen instances, thanks
        self._bots = {bot._bot_id: bot.freeze() for bot in bots}

        self._updater_processes = {}
        self._worker_processes = []
        self._ipc_process = None
        self.ipc = None

        self.running = False
        self._stop = False
        self._started_at = None
        self._last_scheduled_checks = -1

        # Start the IPC server
        self._ipc_server = ipc.IPCServer()
        self.ipc_port = self._ipc_server.port
        self.ipc_auth_key = self._ipc_server.auth_key
        self._ipc_stop_key = self._ipc_server.stop_key

        # Use the MultiprocessingDriver for all the shared memories
        for bot in self._bots.values():
            bot._shared_memory.switch_driver(shared.MultiprocessingDriver())

        self._workers_count = workers

        self.logger = logbook.Logger("botogram runner") 
开发者ID:python-botogram,项目名称:botogram,代码行数:29,代码来源:__init__.py

示例15: __init__

# 需要导入模块: import logbook [as 别名]
# 或者: from logbook import Logger [as 别名]
def __init__(self):
        self.logger = logbook.Logger("botogram IPC server")

        self.commands = {}

        self.auth_key = hashlib.sha1(os.urandom(64)).hexdigest()
        self.stop_key = hashlib.sha1(os.urandom(64)).hexdigest()

        self.stop = False
        self.port, self.conn = self._get_connection() 
开发者ID:python-botogram,项目名称:botogram,代码行数:12,代码来源:ipc.py


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