• loguru


    loguru

    https://loguru.readthedocs.io/en/stable/index.html

    开箱即用,简化用户配置。

    Loguru is a library which aims to bring enjoyable logging in Python.

    Did you ever feel lazy about configuring a logger and used print() instead?… I did, yet logging is fundamental to every application and eases the process of debugging. Using Loguru you have no excuse not to use logging from the start, this is as simple as from loguru import logger.

    Also, this library is intended to make Python logging less painful by adding a bunch of useful functionalities that solve caveats of the standard loggers. Using logs in your application should be an automatism, Loguru tries to make it both pleasant and powerful.

    Ready to use out of the box without boilerplate

    The main concept of Loguru is that there is one and only one logger.

    For convenience, it is pre-configured and outputs to stderr to begin with (but that’s entirely configurable).

    from loguru import logger
    
    logger.debug("That's it, beautiful and simple logging!")
    

    The logger is just an interface which dispatches log messages to configured handlers. Simple, right?

    logging vs loguru

    https://loguru.readthedocs.io/en/stable/resources/migration.html

    Fundamental differences between logging and loguru

    Although loguru is written “from scratch” and does not rely on standard logging internally, both libraries serve the same purpose: provide functionalities to implement a flexible event logging system. The main difference is that standard logging requires the user to explicitly instantiate named Logger and configure them with Handler, Formatter and Filter, while loguru tries to narrow down the amount of configuration steps.

    Apart from that, usage is globally the same, once the logger object is created or imported you can start using it to log messages with the appropriate severity (logger.debug("Dev message"), logger.warning("Danger!"), etc.), messages which are then sent to the configured handlers.

    Logs vs Metrics vs Traces

    https://microsoft.github.io/code-with-engineering-playbook/observability/log-vs-metric-vs-trace/

    Overview

    Metrics

    The purpose of metrics is to inform observers about the health & operations regarding a component or system. A metric represents a point in time measure of a particular source, and data-wise tends to be very small. The compact size allows for efficient collection even at scale in large systems. Metrics also lend themselves very well to pre-aggregation within the component before collection, reducing computation cost for processing & storing large numbers of metric time series in a central system. Due to how efficiently metrics are processed & stored, it lends itself very well for use in automated alerting, as metrics are an excellent source for the health data for all components in the system.

    Logs

    Log data inform observers about the discrete events that occurred within a component or a set of components. Just about every software component log information about its activities over time. This rich data tends to be much larger than metric data and can cause processing issues, especially if components are logging too verbosely. Therefore, using log data to understand the health of an extensive system tends to be avoided and depends on metrics for that data. Once metric telemetry highlights potential problem sources, filtered log data for those sources can be used to understand what occurred.

    Traces

    Where logging provides an overview to a discrete, event-triggered log, tracing encompasses a much wider, continuous view of an application. The goal of tracing is to following a program’s flow and data progression.

    In many instances, tracing represents a single user’s journey through an entire app stack. Its purpose isn’t reactive, but instead focused on optimization. By tracing through a stack, developers can identify bottlenecks and focus on improving performance.

    A distributed trace is defined as a collection of spans. A span is the smallest unit in a trace and represents a piece of the workflow in a distributed landscape. It can be an HTTP request, call to a database, or execution of a message from a queue.

    When a problem does occur, tracing allows you to see how you got there:

    • Which function.
    • The function’s duration.
    • Parameters passed.
    • How deep into the function the user could get.
  • 相关阅读:
    UVA 1557
    基于角色的权限设计(二)
    用DirectShow实现视频採集-流程构建
    oracle中schema指的是什么?
    GCC 命令行具体解释
    希尔排序
    单点登录SSO的实现原理
    济南最新公交线路一览(BRT)
    编写你自己的单点登录(SSO)服务
    C和指针 (pointers on C)——第五章:操作符和表达式
  • 原文地址:https://www.cnblogs.com/lightsong/p/16745426.html
Copyright © 2020-2023  润新知