當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。