# TrackLogging
TrackLogging is a logging package for tracing function calls with error handling and email notification.
## Installation
You can install TrackingLog using pip:
```bash
pip install trackinglog
```
## Github URL
https://github.com/shiyi-yinghao/trackinglog
## PyPi URL
https://pypi.org/project/trackinglog/
## version History
0.1.0 Package Draft created
0.1.1 Decorator get_log and directly object creator get_logger created. Added setup check decorator. Added p-functions(print and log).
0.1.2 Added error handling. Added verbose option for decorator. Added called function name.
0.1.3 Added profiler for both function level and line level. Updated error handling logic: reset verbose to False, but it will now raise error instead. Added class name to log. Added dependency pakages. Added resource performance tracking.
0.1.4 Formatted the logging message with indentation. Add print to log feature. Refactor the get_log function.
0.1.5 Added cache log cleaner.
0.1.6 Updated Log config to Parameter config. Added inline log usage.
## Feature in developing
Add public and private log
Add Added email notification.
Add Kafka message notification
## Uaage for function and quick settings:
```python
import logging
import trackinglog
import inspect
# Setup the LogManager with root logging path
trackinglog.logger.setup(root_task_path='./logs')
@trackinglog.logger.get_log('my_logger', verbose=1, enable_profiling="line")
def my_function(log=None): # Notice how the log parameter is expected
log.info("This function does something important.")
print("Function is executing...")
# assert False, "This function is broken!"
my_function() # Running the function will log start and end, using the specific logger
```
## Usage for class and comprehensive settings:
```python
import logging
import trackinglog
import inspect
trackinglog.logger.setup(root_task_path='./logs', log_config={'root_log_path':"./logs", '_cache_log_path':"./logs/cache", 'cache_log_num_limit':10, '_cache_log_day_limit':7},
email_credential={'username':"PLACEHOLDER", 'password':"PLACEHOLDER", 'root_emails_folder':"./logs/emails"},
lock_config={"lock_folder_path":"./logs/locks"})
@trackinglog.logger.get_log('my_logger_cls', verbose=1, enable_profiling="line", print2log=True)
class testclass:
def __init__(self, a: int):
self.a=a
def p(self):
self.log.info("class log")
# assert False , "This function is broken!"
def count(self, n: int):
for i in range(n):
print(i)
t=testclass(2.2)
t.p()
t.count(3)
```
## Usage inside a function:
```python
trackinglog.logger.setup(root_task_path='./logs')
def my_function():
log=trackinglog.logger.get_logger('my_logger_func')
log.info("This function does something important.")
print("Function is executed")
my_function()
```
## Configuration and Parameters:
trackinglog.logger.setup(root_log_path='./logs')
@trackinglog.logger.get_log('my_logger_cls', verbose=1, enable_profiling="function", print2log=True)
Raw data
{
"_id": null,
"home_page": "https://github.com/shiyi-yinghao/trackinglog",
"name": "trackinglog",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3.11",
"maintainer_email": null,
"keywords": null,
"author": "Yinghao Li",
"author_email": "shiyi.yinghao@gmail.com",
"download_url": "https://files.pythonhosted.org/packages/f1/7a/2e8bdbb2279f44db933062fbf2e9c3434eeeb002a8788fedda2da2b34c1a/trackinglog-0.1.6.tar.gz",
"platform": null,
"description": "# TrackLogging\n\nTrackLogging is a logging package for tracing function calls with error handling and email notification.\n\n## Installation\n\nYou can install TrackingLog using pip:\n\n```bash\npip install trackinglog\n\n```\n\n## Github URL\nhttps://github.com/shiyi-yinghao/trackinglog\n\n## PyPi URL\nhttps://pypi.org/project/trackinglog/\n\n## version History\n\n0.1.0 Package Draft created\n\n0.1.1 Decorator get_log and directly object creator get_logger created. Added setup check decorator. Added p-functions(print and log).\n\n0.1.2 Added error handling. Added verbose option for decorator. Added called function name.\n\n0.1.3 Added profiler for both function level and line level. Updated error handling logic: reset verbose to False, but it will now raise error instead. Added class name to log. Added dependency pakages. Added resource performance tracking.\n\n0.1.4 Formatted the logging message with indentation. Add print to log feature. Refactor the get_log function.\n\n0.1.5 Added cache log cleaner.\n\n0.1.6 Updated Log config to Parameter config. Added inline log usage.\n\n## Feature in developing\n\nAdd public and private log\n\nAdd Added email notification. \n\nAdd Kafka message notification\n\n\n## Uaage for function and quick settings:\n\n```python\nimport logging\nimport trackinglog\nimport inspect\n\n# Setup the LogManager with root logging path\ntrackinglog.logger.setup(root_task_path='./logs')\n\n@trackinglog.logger.get_log('my_logger', verbose=1, enable_profiling=\"line\")\ndef my_function(log=None): # Notice how the log parameter is expected\n log.info(\"This function does something important.\")\n print(\"Function is executing...\")\n # assert False, \"This function is broken!\"\n \nmy_function() # Running the function will log start and end, using the specific logger\n\n```\n\n## Usage for class and comprehensive settings:\n```python\nimport logging\nimport trackinglog\nimport inspect\n\ntrackinglog.logger.setup(root_task_path='./logs', log_config={'root_log_path':\"./logs\", '_cache_log_path':\"./logs/cache\", 'cache_log_num_limit':10, '_cache_log_day_limit':7},\n email_credential={'username':\"PLACEHOLDER\", 'password':\"PLACEHOLDER\", 'root_emails_folder':\"./logs/emails\"},\n lock_config={\"lock_folder_path\":\"./logs/locks\"})\n\n@trackinglog.logger.get_log('my_logger_cls', verbose=1, enable_profiling=\"line\", print2log=True)\nclass testclass:\n def __init__(self, a: int):\n self.a=a\n def p(self):\n self.log.info(\"class log\")\n # assert False , \"This function is broken!\"\n\n def count(self, n: int):\n for i in range(n):\n print(i)\n \n\nt=testclass(2.2)\nt.p()\nt.count(3)\n```\n\n## Usage inside a function:\n```python\ntrackinglog.logger.setup(root_task_path='./logs')\n\ndef my_function():\n log=trackinglog.logger.get_logger('my_logger_func')\n log.info(\"This function does something important.\")\n print(\"Function is executed\")\n\nmy_function() \n```\n\n## Configuration and Parameters:\n\ntrackinglog.logger.setup(root_log_path='./logs')\n@trackinglog.logger.get_log('my_logger_cls', verbose=1, enable_profiling=\"function\", print2log=True)\n",
"bugtrack_url": null,
"license": null,
"summary": "A logging package for tracing function calls with error handling and email notification",
"version": "0.1.6",
"project_urls": {
"Homepage": "https://github.com/shiyi-yinghao/trackinglog"
},
"split_keywords": [],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "830dadc682d66c63662415420cfb54a96c6406e261912956627919185b1bee24",
"md5": "ce815959c304df6b3913dbbf8740956f",
"sha256": "993a0cd983aa5f651c301b41d14e48c37fac8d84b74fec5af21461fdd3e266d0"
},
"downloads": -1,
"filename": "trackinglog-0.1.6-py3-none-any.whl",
"has_sig": false,
"md5_digest": "ce815959c304df6b3913dbbf8740956f",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.11",
"size": 12885,
"upload_time": "2024-09-09T00:34:36",
"upload_time_iso_8601": "2024-09-09T00:34:36.732290Z",
"url": "https://files.pythonhosted.org/packages/83/0d/adc682d66c63662415420cfb54a96c6406e261912956627919185b1bee24/trackinglog-0.1.6-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "f17a2e8bdbb2279f44db933062fbf2e9c3434eeeb002a8788fedda2da2b34c1a",
"md5": "b705de12e13f2c2c1df4a3813e6dc23d",
"sha256": "e835c0df2dcb46a3d7122bb3a05c9a220e34b0591eb1241faa76b4ca26d1623b"
},
"downloads": -1,
"filename": "trackinglog-0.1.6.tar.gz",
"has_sig": false,
"md5_digest": "b705de12e13f2c2c1df4a3813e6dc23d",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.11",
"size": 10498,
"upload_time": "2024-09-09T00:34:38",
"upload_time_iso_8601": "2024-09-09T00:34:38.643679Z",
"url": "https://files.pythonhosted.org/packages/f1/7a/2e8bdbb2279f44db933062fbf2e9c3434eeeb002a8788fedda2da2b34c1a/trackinglog-0.1.6.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-09-09 00:34:38",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "shiyi-yinghao",
"github_project": "trackinglog",
"travis_ci": false,
"coveralls": false,
"github_actions": false,
"lcname": "trackinglog"
}