Skip to main content

exec-log

exec-log 是一个日志输出项目,在loguru的基础集成日志输出到控制台、输出到Slack、并结合CMRESHandler把日记记录到ElasticSearch, 更容易的对日志进行分析。

Installation

1.使用python包管理工具 pip 进行安装。

pip install exec-log

Usage

对exec-log进行配置,并输出日志信息。 日志分为7个级别: TRACE(5) / DEBUG(10) / INFO(20) / SUCCESS(25) / WARNING(30) / ERROR(40) / CRITICAL(50)

from execlog.setlogs import Logger

logger = Logger(
    webhook_url='Your Slack webhook URL',  # Slack webhook URL  # noqa
    es_hosts=['172.0.0.1:9200'],  # 记录日期 ElasticSearch host ip and port
    # log_path=f'{proj_root}/site/logs/running_status.log' # 如果不用ElasticSearch可以自定义log保存路径或使用默认路径
)

if __name__ == '__main__':
    logger.echo('输出到控制台')
    logger.app("发送到Slack")
    logger.trace('输出到控制台,并写入ElasticSearch或本地', note='这个参数只会在ES显示,ES会添加字段名为extra.note, <<note参数名>>可以随情况更改,<<也可以不设置>>, 相应ES字段名也会动态更改。')
    logger.debug('输出到控制台,并写入ElasticSearch或本地', note='这个参数只会在ES显示,ES会添加字段名为extra.note, <<note参数名>>可以随情况更改,<<也可以不设置>>, 相应ES字段名也会动态更改。')
    logger.info('输出到控制台,并写入ElasticSearch或本地', note='这个参数只会在ES显示,ES会添加字段名为extra.note, <<note参数名>>可以随情况更改,<<也可以不设置>>, 相应ES字段名也会动态更改。')
    logger.success('输出到控制台,并写入ElasticSearch或本地', note='这个参数只会在ES显示,ES会添加字段名为extra.note, <<note参数名>>可以随情况更改,<<也可以不设置>>, 相应ES字段名也会动态更改。')
    logger.warning('输出到控制台,并写入ElasticSearch或本地', note='这个参数只会在ES显示,ES会添加字段名为extra.note, <<note参数名>>可以随情况更改,<<也可以不设置>>, 相应ES字段名也会动态更改。')
    logger.error('输出到控制台,并写入ElasticSearch或本地', note='这个参数只会在ES显示,ES会添加字段名为extra.note, <<note参数名>>可以随情况更改,<<也可以不设置>>, 相应ES字段名也会动态更改。')
    logger.critical('输出到控制台,并写入ElasticSearch或本地', note='这个参数只会在ES显示,ES会添加字段名为extra.note, <<note参数名>>可以随情况更改,<<也可以不设置>>, 相应ES字段名也会动态更改。')
    logger.notice('输出到控制台和Slack,并写入ElasticSearch或本地', level='INFO', note='这个参数只会在ES显示,ES会添加字段名为extra.note, <<note参数名>>可以随情况更改,<<也可以不设置>>, 相应ES字段名也会动态更改。')

Contributing

欢迎使用,如果有好的优化方法也欢迎提交修改。

使用前请做适当的测试,以确定跟您的项目完全兼容。

License

MIT

Metadata

Release files for exec-log 0.1.8

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for exec-log 0.1.8
File Size Uploaded Provenance Actions
exec-log-0.1.8.tar.gz 7.4 kB Without provenance Details for exec-log-0.1.8.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for exec-log 0.1.8
File Interpreter ABI Platform Actions
exec_log-0.1.8-py3-none-any.whl Python 3 none any Details for exec_log-0.1.8-py3-none-any.whl

Total release size: 14.7 kB

Release files / exec-log-0.1.8.tar.gz

Download URL exec-log-0.1.8.tar.gz
Size 7.4 kB
Tags Source
SHA-256 checksum
How to use checksums
8804ec42c0849235ed897494f08121526bf13ae11adec9ef897b82365228dec0
BLAKE2b-256 checksum
How to use checksums
15a3cea9c012fd8f6db5cf844e3f3aad1145a31bd9b17bdbc6b780258459f56d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.7.1 importlib_metadata/4.10.1 pkginfo/1.8.2 requests/2.27.1 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.10.2

Release files / exec_log-0.1.8-py3-none-any.whl

Download URL exec_log-0.1.8-py3-none-any.whl
Size 7.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
bd29507ead144db659969fd9998822037106d50ef5b7cf8c49fbcd91f8f4c87a
BLAKE2b-256 checksum
How to use checksums
371f11685b440ea93d658680bd4f8555f628bb3ce6ef280bf4d584d58e449c85
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.7.1 importlib_metadata/4.10.1 pkginfo/1.8.2 requests/2.27.1 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.10.2

Security for exec-log 0.1.8

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page