lithoxyl

Application instrumentation and logging, with a geological bent. Documentation is available on Read the Docs.

An infomercial of sorts

"Has this ever happened to you?"

Here's an example of some ostensibly well-instrumented code.

import logging

def create_user(name):
    logging.info('creating user with name %r', name)
    try:
        success = _create_user(name)
        if success:
            logging.info('successfully created user %r', name)
        else:
            logging.error('failed to create user %r', name)
    except Exception:
        logging.critical('exception encountered while creating user %r',
                         name, exc_info=True)
    return success

Notice how the logging statements tend to dominate the code, almost drowning out the meaning of the code.

Here's lithoxyl's take:

from lithoxyl import stderr_log

def create_user(name):
    with stderr_log.critical('user creation', username=name, reraise=False) as r:
        success = _create_user(name)
        if not success:
            r.failure()
    return success

Feature brief

  • Transactional logging
  • Semantic instrumentation
  • Pure Python
  • Pythonic context manager API minimizes developer errors
  • Decorator syntax is convenient and unobtrusive
  • Human-readable structured logs
  • Reparseability thanks to autoescaping
  • Statistical accumulators for prerolled metrics
  • Programmatic configuration with sensible defaults just an import away
  • Synchronous mode for simplicity
  • Asynchronous operation for performance critical applications
  • Log file headers for metadata handling
  • Heartbeat for periodic output and checkpointing
  • Automatic, fast log parser generation (TBI)
  • Sinks
    • EWMASink
    • DebuggerSink
    • MomentSink
    • QuantileSink
    • StreamSink
    • SyslogSink
    • and more

Reasons to use Lithoxyl

  • More specific: distinguishes between level and status
  • Safer: Transactional logging ensures that exceptions are always recorded appropriately
  • Lower overhead: Lithoxyl can be used more places in code (e.g., tight loops), as well as more environments, without concern of excess overhead.
  • More Pythonic: Python's logging module is a port of log4j, and it shows.
  • No global state: Lithoxyl has virtually no internal global state, meaning fewer gotchas overall
  • Higher concurrency: less global state and less overhead mean fewer places where contention can occur
  • More succinct: Rather than try/except/finally, use a simple with block
  • More useful: Lithoxyl represents a balance between logging and profiling
  • More composable: Get exactly what you want by recombining new and provided components
  • More lightweight: Simplicity, composability, and practicality, make Lithoxyl something one might reach for earlier in the development process. Logging shouldn't be an afterthought, nor should it be a big investment that weighs down development, maintenance, and refactoring.


lithoxyl

应用仪器和测井,具有地质 弯曲。文档可用 阅读文档

一种电子商务类型

这是否发生在你身上?

这是一些表面上很好的仪器化代码的例子。

import logging

def create_user(name): logging.info('creating user with name %r', name) try: success = _create_user(name) if success: logging.info('successfully created user %r', name) else: logging.error('failed to create user %r', name) except Exception: logging.critical('exception encountered while creating user %r', name, exc_info=True) return success

注意,日志记录语句几乎可以主导代码 淹没了代码的意思。

这是lithoxyl的采取:

from lithoxyl import stderr_log

def create_user(name): with stderr_log.critical('user creation', username=name, reraise=False) as r: success = _create_user(name) if not success: r.failure() return success

功能简介

  • 事务记录
  • 语义工具
  • 纯Python
  • Pythonic上下文管理器API可最大限度地减少开发人员错误
  • 装饰器语法方便而且不引人注意
  • 可读结构化日志
  • 由于自动转义
  • 可以恢复
  • 用于预先滚动的指标的统计累加器
  • 具有合理默认值的程序化配置只需导入
  • 简单的同步模式
  • 性能关键应用程序的异步操作
  • 用于元数据处理的日志文件头
  • 定期输出和检查点的心跳
  • 自动快速日志解析器生成(TBI)
  • 下水道
    • EWMASink
    • DebuggerSink
    • MomentSink
    • QuantileSink
    • StreamSink
    • SyslogSink

使用Lithoxyl的原因

  • 更具体:区分级别和状态
  • 更安全:事务日志记录确保异常始终能够正确记录
  • 降低开销:在不考虑额外开销的情况下,可以在代码中使用更多的地方(例如紧密环路)以及更多的环境。
  • 更多Pythonic:Python的日志记录模块是log4j的端口,它显示。
  • 没有全球性的状态:Lylhoxyl几乎没有内部的全球性状态,意味着总体上更少的陷阱
  • 更高的并发性:更少的全局状态和更少的开销意味着更少的争用可能发生的地方
  • 更简洁:而不是尝试/ except / finally,使用一个简单的阻止
  • 更有用:Lithoxyl代表记录和分析之间的平衡
  • 更易于组合:通过重新组合新的和提供的组件来获得您想要的内容
  • 更轻巧:简单,可组合性和实用性,使得在开发过程中可以达到的一些可能达到的。日志不应该是事后的想法,也不应该是一个重大的开发,维护和重构的大投资。




相关问题推荐