Name | m-formatter-logging JSON |
Version |
1.0.6
JSON |
| download |
home_page | |
Summary | MobioLogging |
upload_time | 2024-03-19 10:21:27 |
maintainer | |
docs_url | None |
author | MOBIO |
requires_python | >=3.8 |
license | |
keywords |
|
VCS |
|
bugtrack_url |
|
requirements |
No requirements were recorded.
|
Travis-CI |
No Travis.
|
coveralls test coverage |
No coveralls.
|
# m-formatter-logging là thư viện python để write log cho các module BackEnd-Mobio
#### Version:
Phiên bản hiện tại `1.0.6`
#### Cài đặt:
`pip3 install m-formatter-logging`
#### Sử dụng:
1. Gọi func log tương ứng với level mong muốn.
- Sử dụng tham số `sensitive=True` (default=False) trong trường hợp dữ liệu log có data nhạy cảm (Ví dụ: thông tin PII của profile, mật khẩu của user, mã voucher,...).
- Sử dụng key extra để log thêm thông tin (chỉ show trên hệ thống ELK).
```
if __name__ == '__main__':
def test():
MobioLogging().info('app_test_lib_logging::test():info', sensitive=True, extra={"key1": "value1"})
try:
a = 1 / 0
MobioLogging().info('__init__::test():a: %s' % a)
except Exception as ex1:
MobioLogging().error('app_test_lib_logging::test():error: %s' % ex1, sensitive=True)
MobioLogging().debug('app_test_lib_logging::test():debug')
MobioLogging().warning('app_test_lib_logging::test():warning', sensitive=False)
test()
```
2. Sử dụng file custom config:
```
config_file_path = 'path/to/config/file'
MobioLogging().file_config(self, config_file_path)
```
3. Sử dụng custom filter để xử lý cụ thể 1 trường hợp log:
```
class CustomizeFilterRecords():
def filter(self, record):
if record.key1 == 'value1':
return False # no log
return True
MobioLogging().logger.addFilter(CustomizeFilterRecords())
```
#### Changelog:
##### v1.0.6:
* Bỏ fix version dependency configparser
##### v1.0.4:
* Cập nhật lại mô tả trong README.
##### v1.0.3:
* Phiên bản đầu tiên.
Raw data
{
"_id": null,
"home_page": "",
"name": "m-formatter-logging",
"maintainer": "",
"docs_url": null,
"requires_python": ">=3.8",
"maintainer_email": "",
"keywords": "",
"author": "MOBIO",
"author_email": "contact@mobio.io",
"download_url": "https://files.pythonhosted.org/packages/81/27/76df8db43dc3c68a800c73dfb5a2263f34b1c78aaedbbd5e62b190391641/m-formatter-logging-1.0.6.tar.gz",
"platform": null,
"description": "# m-formatter-logging l\u00e0 th\u01b0 vi\u1ec7n python \u0111\u1ec3 write log cho c\u00e1c module BackEnd-Mobio\n\n#### Version:\nPhi\u00ean b\u1ea3n hi\u1ec7n t\u1ea1i `1.0.6`\n\n#### C\u00e0i \u0111\u1eb7t:\n`pip3 install m-formatter-logging`\n\n#### S\u1eed d\u1ee5ng:\n1. G\u1ecdi func log t\u01b0\u01a1ng \u1ee9ng v\u1edbi level mong mu\u1ed1n.\n- S\u1eed d\u1ee5ng tham s\u1ed1 `sensitive=True` (default=False) trong tr\u01b0\u1eddng h\u1ee3p d\u1eef li\u1ec7u log c\u00f3 data nh\u1ea1y c\u1ea3m (V\u00ed d\u1ee5: th\u00f4ng tin PII c\u1ee7a profile, m\u1eadt kh\u1ea9u c\u1ee7a user, m\u00e3 voucher,...).\n- S\u1eed d\u1ee5ng key extra \u0111\u1ec3 log th\u00eam th\u00f4ng tin (ch\u1ec9 show tr\u00ean h\u1ec7 th\u1ed1ng ELK).\n```\nif __name__ == '__main__':\n def test():\n MobioLogging().info('app_test_lib_logging::test():info', sensitive=True, extra={\"key1\": \"value1\"})\n try:\n a = 1 / 0\n MobioLogging().info('__init__::test():a: %s' % a)\n except Exception as ex1:\n MobioLogging().error('app_test_lib_logging::test():error: %s' % ex1, sensitive=True)\n\n MobioLogging().debug('app_test_lib_logging::test():debug')\n MobioLogging().warning('app_test_lib_logging::test():warning', sensitive=False)\n\n test()\n```\n\n\n2. S\u1eed d\u1ee5ng file custom config:\n```\nconfig_file_path = 'path/to/config/file'\nMobioLogging().file_config(self, config_file_path)\n```\n\n\n3. S\u1eed d\u1ee5ng custom filter \u0111\u1ec3 x\u1eed l\u00fd c\u1ee5 th\u1ec3 1 tr\u01b0\u1eddng h\u1ee3p log:\n```\nclass CustomizeFilterRecords():\n def filter(self, record):\n if record.key1 == 'value1':\n return False # no log\n return True\n\nMobioLogging().logger.addFilter(CustomizeFilterRecords())\n```\n\n#### Changelog:\n\n##### v1.0.6:\n* B\u1ecf fix version dependency configparser\n\n##### v1.0.4:\n* C\u1eadp nh\u1eadt l\u1ea1i m\u00f4 t\u1ea3 trong README.\n\n##### v1.0.3:\n* Phi\u00ean b\u1ea3n \u0111\u1ea7u ti\u00ean.\n",
"bugtrack_url": null,
"license": "",
"summary": "MobioLogging",
"version": "1.0.6",
"project_urls": null,
"split_keywords": [],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "812776df8db43dc3c68a800c73dfb5a2263f34b1c78aaedbbd5e62b190391641",
"md5": "bc0e6aad126d5d87a6cf49e2743a5a4d",
"sha256": "a448aabfb62e178f6309b496fc37c72ce5dfcba0266acc05e2da83d90064c6e9"
},
"downloads": -1,
"filename": "m-formatter-logging-1.0.6.tar.gz",
"has_sig": false,
"md5_digest": "bc0e6aad126d5d87a6cf49e2743a5a4d",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.8",
"size": 4366,
"upload_time": "2024-03-19T10:21:27",
"upload_time_iso_8601": "2024-03-19T10:21:27.059604Z",
"url": "https://files.pythonhosted.org/packages/81/27/76df8db43dc3c68a800c73dfb5a2263f34b1c78aaedbbd5e62b190391641/m-formatter-logging-1.0.6.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-03-19 10:21:27",
"github": false,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"lcname": "m-formatter-logging"
}