Common Logger
Project description
logpilot
logpilot is a project to extend python standard logging to offer customizing ability.
Install
pip install logpilot
Log format
we only support format like this:
#--------------------------------------------------
# 日志格式
#--------------------------------------------------
# %(asctime)s.%(msecs)03d 年-月-日 时:分:秒 2016-01-01 00:00:00.000
# %(filename)s 文件名,不含目录
# %(pathname)s 目录名,完整路径
# %(funcName)s 函数名
# %(levelname)s 级别名
# %(lineno)d 行号
# %(module)s 模块名
# %(message)s 消息体
# %(name)s 日志模块名
# %(processName)s 进程名
# %(threadName)s 线程名
# %(hostname)s FQDN
# %(uuid)s 跟踪id,可以是sha256或者job id
# %(elapsed)s 耗时(ms)
%(asctime)s.%(msecs)03d|%(levelname)s|%(name)s|%(filename)s|%(lineno)d|%(module)s|%(funcName)s|%(processName)s|%(threadName)s|%(message)s|%(hostname)s|%(uuid)s|%(elapsed)s
How to use
from logpilot.log import Log
log = Log.get_logger(__name__)
class Example(object):
def __init__(self):
log.info(msg="this is a test for logpilot", uuid="2b24bad1c5df6b4551768fe09ae877b893fc35505847e80f119c395bca27", elapsed=256)
example log
2016-11-17 14:35:59|DEBUG|__main__|test2_log.py|11|test2_log|__init__|MainProcess|MainThread|this is a test for logpilot|localhost|2b24bad1c5df6b4551768fe09ae877b893fc35505847e80f119c395bca27|256
How to set global uuid
from logpilot.log import Log
log = Log.get_logger(__name__, uuid='hsdfhkd')
log.info(msg="this is a test logpilot", elapsed=8888)
log.info(msg='hahah', uuid='5678')
log.debug(msg="android world", elapsed=234)
# notice that uuid also can be override
log.error(msg="ios world", uuid='jaj', elapsed=99)
How to change log level
default DEBUG
import logging
from logpilot.log import Log
log = Log.get_logger('test2222')
log.logger.setLevel(logging.INFO)
class Test(object):
def __init__(self):
log.info(msg="this is a test logpilot", hahah='hooooo.', age=10000, fake_key='not valid')
if __name__ == '__main__':
from logpilot.log import Log
a = Test()
log.debug(msg="this is a test logpilot", hahah='hooooo.', uuid="1234567890")
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
logpilot-0.0.2b2.tar.gz
(5.6 kB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file logpilot-0.0.2b2.tar.gz.
File metadata
- Download URL: logpilot-0.0.2b2.tar.gz
- Upload date:
- Size: 5.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.9.18
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
77c79edc170529716dfd831b8b1ad71a6092bf10de5cf575cc7cc7d12b934144
|
|
| MD5 |
d328292a975df427ed541354ef09cc7f
|
|
| BLAKE2b-256 |
0202d39d374688d47f2ebd927b2c990e93fb4f5ef0bea11225fb4d10b0d9efee
|
File details
Details for the file logpilot-0.0.2b2-py2.py3-none-any.whl.
File metadata
- Download URL: logpilot-0.0.2b2-py2.py3-none-any.whl
- Upload date:
- Size: 4.3 kB
- Tags: Python 2, Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.9.18
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5d36245b9aff7570ddba096a3134bde835397f622619725432c38e1cf8b671cd
|
|
| MD5 |
045c59a02420d3a8a676d49567a23876
|
|
| BLAKE2b-256 |
d0c269d8dd45971c30e627861f69a54e47b9f6b9dc765d01a0989ad69b6577b1
|