Skip to main content

Project logging

Project description

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

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

exec-log-0.1.8.tar.gz (7.4 kB view details)

Uploaded Source

Built Distribution

exec_log-0.1.8-py3-none-any.whl (7.2 kB view details)

Uploaded Python 3

File details

Details for the file exec-log-0.1.8.tar.gz.

File metadata

  • Download URL: exec-log-0.1.8.tar.gz
  • Upload date:
  • Size: 7.4 kB
  • Tags: Source
  • Uploaded using 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

File hashes

Hashes for exec-log-0.1.8.tar.gz
Algorithm Hash digest
SHA256 8804ec42c0849235ed897494f08121526bf13ae11adec9ef897b82365228dec0
MD5 97c11179b51c952ab11a4bf38da7f6bc
BLAKE2b-256 15a3cea9c012fd8f6db5cf844e3f3aad1145a31bd9b17bdbc6b780258459f56d

See more details on using hashes here.

File details

Details for the file exec_log-0.1.8-py3-none-any.whl.

File metadata

  • Download URL: exec_log-0.1.8-py3-none-any.whl
  • Upload date:
  • Size: 7.2 kB
  • Tags: Python 3
  • Uploaded using 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

File hashes

Hashes for exec_log-0.1.8-py3-none-any.whl
Algorithm Hash digest
SHA256 bd29507ead144db659969fd9998822037106d50ef5b7cf8c49fbcd91f8f4c87a
MD5 c175581a5359a681c106307120cec080
BLAKE2b-256 371f11685b440ea93d658680bd4f8555f628bb3ce6ef280bf4d584d58e449c85

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page