Skip to main content

sentry-logging

Project description

SentryLog

基于 Python-Logging 日志拓展

  • 封装了 Sentry日志输出
  • 增加了 默认的日志出颜色

安装步骤

pip install -r requirements.txt

环境要求

1.Win 系统: 请查看文档 https://www.python.org/ftp/python/ 

2.Linux 系统:

1)下载
wget https://www.python.org/ftp/python/3.7.0/Python-3.7.0.tgz

2)解压Python-3.7.0.tgz
tar -zxvf Python-3.7.0.tgz

3)建立一个空文件夹,用于存放python3程序 
mkdir /usr/local/python3 

4)执行配置文件,编译,编译安装 
cd Python-3.7.0
./configure --prefix=/usr/local/python3
make && make install

5)建立软连接
ln -s /usr/local/python3/bin/python3.7 /usr/bin/python3
ln -s /usr/local/python3/bin/pip3.7 /usr/bin/pip3

6)测试一下python3是否可以用 
python3

案例

log_test : 存在小部分测试用例

配置说明

由于logging配置文件种类较多,以conf文件做一下说明
日志的大致流程:

输入--- 加载配置 ---- 加载处理器 ---- 加载格式 ---- 输出

通常来配置的有

1. 处理的配置
 -1- 输出的位置
 -2- 自定义输出
2. 格式的配置
 -1- 输出消息的格式
 -2- 自定义输出

需要注意:
由于logging 中源码中的Config对格式读取有一定的局限性,比如说自定义传参可能无法满足,如果需要请自行修改源码做适配

loggers

[loggers]
keys=x,y,z
x,y,z : 代表logging-name,也就是对应logging的名称,再配置文件中充当实例的身份上下文做分类,支持多个配置,根据不同的环境实例化供选择

比如说
logger_x : 属于x的配置

-------

[handlers]
keys=h1,h2,h3
h1,h2,h3 : 代表logging-handler, 用来处理日志输出的位置,同样支持多个配置,执行流程先进先出的流程,

比如说指定了h1,h2,h3 handlers同时都引用了,那么日志的输出顺序是 h1-->h2-->h3

-------


[logger_x]
handlers=h1,h2,h3
propagate # 传播,如果子handler中没有输出会默认找父类的输出
qualname # 身份辨识

作用就是引用handlers 


-------

[handler_x]
class # 指定 处理日志的处理器 ,支持自定义
level # 日志过滤级别
formatter # 指定 处理后日志输出的格式,这里是一个身份识别的上下文,
args # 处理器的所需要的参数,详情见官网

-------

[formatter_x]
class # 默认的话走原生的格式出书,支持自定义
format # 指定日志输出的格式

这里需要注意的: 如果自定义通过args传参的话,并非适配所有的参数,源码比较固定

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

sentrylog-0.0.3.tar.gz (5.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

sentrylog-0.0.3-py3-none-any.whl (7.9 kB view details)

Uploaded Python 3

File details

Details for the file sentrylog-0.0.3.tar.gz.

File metadata

  • Download URL: sentrylog-0.0.3.tar.gz
  • Upload date:
  • Size: 5.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.8.0 pkginfo/1.8.2 readme-renderer/33.0 requests/2.25.1 requests-toolbelt/0.9.1 urllib3/1.26.2 tqdm/4.60.0 importlib-metadata/4.10.0 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.7.1

File hashes

Hashes for sentrylog-0.0.3.tar.gz
Algorithm Hash digest
SHA256 5eec163ea64c6ac20c894d515e97e9aa6b842e753febf99712f2078d775caabb
MD5 8727bebb36748f5fee8c4f4d0645907b
BLAKE2b-256 6ef263842e2ad0a2217d1c95a7b479f594fd1a7e8860fdb388ec6b2171068e0c

See more details on using hashes here.

File details

Details for the file sentrylog-0.0.3-py3-none-any.whl.

File metadata

  • Download URL: sentrylog-0.0.3-py3-none-any.whl
  • Upload date:
  • Size: 7.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.8.0 pkginfo/1.8.2 readme-renderer/33.0 requests/2.25.1 requests-toolbelt/0.9.1 urllib3/1.26.2 tqdm/4.60.0 importlib-metadata/4.10.0 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.7.1

File hashes

Hashes for sentrylog-0.0.3-py3-none-any.whl
Algorithm Hash digest
SHA256 c3dc471eb0089091d680f86f03d546e29d7ff946cc905966f20206576a1cf583
MD5 f3b30e225828263c40687b634347df68
BLAKE2b-256 ac96c37ad1b62036695add751dd47bb49f8ce78444a9f330ee7eeacb95d981e2

See more details on using hashes here.

Supported by

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