# logEZ
Make logging easy in your applications! Use this simple library to easily use logs in any of your applications.
## Installation
```bash
pip install logEZ
```
## How to use
```python
from logEZ import MyLogger
logger = MyLogger()
```
More in [Sample App](./sample_app.md)
### `MyLogger` class
The __init__ method of the MyLogger class takes four optional arguments:
* `log_file_name`
* `logging_level`
* `disable_console_logs`
* `disable_file_logs`
The default values are:
```python
log_file_name="logEZ.log",
logging_level="INFO",
disable_console_logs=False,
disable_file_logs=False
```
* `log_file_name`: Specify the file name of your log file here.
* `logging_level`: Specify the default logging level of your logs. It can be `INFO`, `DEBUG`, `WARNING`, `ERROR`, or `CRITICAL`.
* `disable_console_logs`: Disable the console logging of your logs, if set to `True`.
* `disable_file_logs`: Disable the file logging of your logs, if set to `True`.
### `MyLogger` methods
Once you have initialized a MyLogger object, you can use the following methods:
* `setLoggingLevel(level: str)`: Change the logging level after initializing `MyLogger()`. (Refer to logging_level under [`MyLogger` class](#mylogger-class) for levels.)
* `debug(inString: str)`: Log a `DEBUG` level message. Accepts a string input.
* `info(inString: str)`: Log an `INFO` level message. Accepts a string input.
* `warning(inString: str)`: Log a `WARNING` level message. Accepts a string input.
* `error(inString: str, exc_info: Optional[bool] = False)`: Log an `ERROR` level message. Accepts a string input. If `exc_info` is set to True, it appends the complete execution information along with the log string.
* `critical(inString: str, exc_info: Optional[bool] = False)`: Log a `CRITICAL` level message. Accepts a string input. If `exc_info` is set to True, it appends the complete execution information along with the log string.
* `myExcept(inString: str)`: Log an exception message. Accepts a string input.
#### Using `exc_info` to send complete execution information
The `exc_info` parameter is an optional argument available in the `error` and `critical` methods of the `MyLogger` class. When set to `True`, it appends the complete execution information, including the traceback, along with the log message. This can be particularly useful when debugging errors or critical issues that require detailed information about the context in which they occurred.
Here's an example of how to use the `exc_info` parameter with myError and `critical` methods:
```python
from logEZ import MyLogger
logger = MyLogger()
def divide(a, b):
try:
result = a / b
except ZeroDivisionError as e:
logger.myError(f"An error occurred while dividing {a} by {b}", exc_info=True)
return None
return result
divide(10, 0)
```
In this example, we have a `divide` function that takes two numbers as arguments and attempts to perform a division operation. If a `ZeroDivisionError` exception is raised, the `error` method is called with the `exc_info` parameter set to `True`. This will log the error message along with the complete execution information, including the traceback, making it easier to understand the context in which the error occurred.
The output of this code will be:
```bash
01-04-23 14:35:28 - root : ERROR : An error occurred while dividing 10 by 0
Traceback (most recent call last):
File "example.py", line 7, in divide
result = a / b
ZeroDivisionError: division by zero
```
Similarly, you can use the `exc_info` parameter with the `critical` method if you want to log critical messages with complete execution information.
## Why use logEZ?
The logEZ library provides a simplified interface to work with the standard logging module in Python. While it does not introduce any new functionality or significant improvements over the built-in logging module, it may be helpful for developers who want a more straightforward, easy-to-use API for common logging tasks.
Advantages of logEZ:
1. Simplified initialization: The logEZ library makes it easier to set up logging with default values and simple customization options. You can easily configure log file names, logging levels, and toggle console or file logging with just a few parameters.
2. Unified logging methods: The logEZ library offers a single class, MyLogger, with methods for different logging levels (debug, info, warning, error, critical), making it more convenient to use compared to the standard logging module, which requires calling separate functions for each logging level.
3. Easier traceback logging: The logEZ library provides the exc_info parameter for error and critical level logs, making it more straightforward to include traceback information when logging exceptions.
However, for more advanced logging use cases or if you require fine-grained control over your logging configuration, the built-in logging module offers more comprehensive features and flexibility. If you are already familiar with the standard logging module, you may not find logEZ to be significantly more helpful.
In summary, the logEZ library can be useful for developers looking for a simpler and more accessible interface for basic logging tasks. However, it might not offer substantial advantages over the built-in logging module for more experienced users or advanced logging scenarios.
## What's next?
We have some exciting plans for the future development of logEZ, and we're always looking for ways to make it even more useful for our users. Here's a list of features we're considering adding:
1. Configuration from file support
2. Log rotation functionality
3. Support for custom log handlers
4. Colored console logs
5. Enhanced context information in log messages
6. Improved exception handling and logging
7. Integrated performance metrics
8. Advanced filtering capabilities
9. Asynchronous logging support
10. Better documentation and examples
_We're open to contributions!_ If you'd like to help implement any of these features or have suggestions for improvements, please feel free to reach out to us. You can contact us at [gehlotkunal@outlook.com](mailto:gehlotkunal@outlook.com) or connect with us on Twitter at [@ZackCodesAI](https://twitter.com/ZackCodesAI).
We're looking forward to collaborating with the community to make logEZ an even more valuable and versatile logging library for Python developers!
# Change Log
## Unreleased
## [0.1.0]
### Updated
- Refactored the code to adhere to PEP8 standards for better readability and maintainability.
- Added type hints to function signatures for improved code comprehension and editor support.
- Improved exception handling with more specific exceptions and error messages.
- Modularized the code into separate files for better organization and extensibility:
- `mylogger.py`: Contains the main `MyLogger` class.
- `handlers.py`: Contains handlers for logging to files and consoles.
- `formatters.py`: Contains the log formatter used for log messages.
- Updated the `__init__.py` file to import necessary components for easier library usage.
- Enhanced the library with docstrings for better documentation and understanding.
- Updated the `README.md` file to provide clearer instructions on how to use the library, including examples and explanations of the new features.
- Improved the `setup.py` file to adhere to the latest Python norms and standards.
- Added `nox` as a development dependency to simplify the development workflow.
## [0.0.3] - 2022-05-08
### Updated
- Updated code with method name fix and logging level method.
- Added "How to use" with complete method definition in README.md
## [0.0.2] - 2022-05-08
### Fixed
- Fixing project directory name
## [0.0.1] - 2022-05-08
### Added
- First Release
### Removed
- Removed `requirements.txt`
- Removed `logging` from `install_requires`
Raw data
{
"_id": null,
"home_page": "https://github.com/KunalGehlot/logEZ",
"name": "logEZ",
"maintainer": "",
"docs_url": null,
"requires_python": ">=3.8",
"maintainer_email": "",
"keywords": "logging",
"author": "Zackcodes.ai",
"author_email": "gehlotkunal@outlook.com",
"download_url": "https://files.pythonhosted.org/packages/d4/4a/1a78fa74a44175bc6e7167d4bf6103c68521712131b883d58ba5f435a100/logEZ-0.1.0.tar.gz",
"platform": null,
"description": "# logEZ\n\nMake logging easy in your applications! Use this simple library to easily use logs in any of your applications.\n\n## Installation\n\n```bash\npip install logEZ\n```\n\n## How to use\n\n```python\nfrom logEZ import MyLogger\n\nlogger = MyLogger()\n```\n\nMore in [Sample App](./sample_app.md)\n\n### `MyLogger` class\n\nThe __init__ method of the MyLogger class takes four optional arguments:\n\n* `log_file_name`\n* `logging_level`\n* `disable_console_logs`\n* `disable_file_logs`\n\nThe default values are:\n\n```python\nlog_file_name=\"logEZ.log\",\nlogging_level=\"INFO\",\ndisable_console_logs=False,\ndisable_file_logs=False\n```\n\n* `log_file_name`: Specify the file name of your log file here.\n* `logging_level`: Specify the default logging level of your logs. It can be `INFO`, `DEBUG`, `WARNING`, `ERROR`, or `CRITICAL`.\n* `disable_console_logs`: Disable the console logging of your logs, if set to `True`.\n* `disable_file_logs`: Disable the file logging of your logs, if set to `True`.\n\n### `MyLogger` methods\n\nOnce you have initialized a MyLogger object, you can use the following methods:\n\n* `setLoggingLevel(level: str)`: Change the logging level after initializing `MyLogger()`. (Refer to logging_level under [`MyLogger` class](#mylogger-class) for levels.)\n* `debug(inString: str)`: Log a `DEBUG` level message. Accepts a string input.\n* `info(inString: str)`: Log an `INFO` level message. Accepts a string input.\n* `warning(inString: str)`: Log a `WARNING` level message. Accepts a string input.\n* `error(inString: str, exc_info: Optional[bool] = False)`: Log an `ERROR` level message. Accepts a string input. If `exc_info` is set to True, it appends the complete execution information along with the log string.\n* `critical(inString: str, exc_info: Optional[bool] = False)`: Log a `CRITICAL` level message. Accepts a string input. If `exc_info` is set to True, it appends the complete execution information along with the log string.\n* `myExcept(inString: str)`: Log an exception message. Accepts a string input.\n\n#### Using `exc_info` to send complete execution information\n\nThe `exc_info` parameter is an optional argument available in the `error` and `critical` methods of the `MyLogger` class. When set to `True`, it appends the complete execution information, including the traceback, along with the log message. This can be particularly useful when debugging errors or critical issues that require detailed information about the context in which they occurred.\n\nHere's an example of how to use the `exc_info` parameter with myError and `critical` methods:\n\n```python\nfrom logEZ import MyLogger\n\nlogger = MyLogger()\n\ndef divide(a, b):\n try:\n result = a / b\n except ZeroDivisionError as e:\n logger.myError(f\"An error occurred while dividing {a} by {b}\", exc_info=True)\n return None\n return result\n\ndivide(10, 0)\n```\n\nIn this example, we have a `divide` function that takes two numbers as arguments and attempts to perform a division operation. If a `ZeroDivisionError` exception is raised, the `error` method is called with the `exc_info` parameter set to `True`. This will log the error message along with the complete execution information, including the traceback, making it easier to understand the context in which the error occurred.\n\nThe output of this code will be:\n\n```bash\n01-04-23 14:35:28 - root : ERROR : An error occurred while dividing 10 by 0\nTraceback (most recent call last):\n File \"example.py\", line 7, in divide\n result = a / b\nZeroDivisionError: division by zero\n```\n\nSimilarly, you can use the `exc_info` parameter with the `critical` method if you want to log critical messages with complete execution information.\n\n## Why use logEZ?\n\nThe logEZ library provides a simplified interface to work with the standard logging module in Python. While it does not introduce any new functionality or significant improvements over the built-in logging module, it may be helpful for developers who want a more straightforward, easy-to-use API for common logging tasks.\n\nAdvantages of logEZ:\n\n1. Simplified initialization: The logEZ library makes it easier to set up logging with default values and simple customization options. You can easily configure log file names, logging levels, and toggle console or file logging with just a few parameters.\n2. Unified logging methods: The logEZ library offers a single class, MyLogger, with methods for different logging levels (debug, info, warning, error, critical), making it more convenient to use compared to the standard logging module, which requires calling separate functions for each logging level.\n3. Easier traceback logging: The logEZ library provides the exc_info parameter for error and critical level logs, making it more straightforward to include traceback information when logging exceptions.\n\nHowever, for more advanced logging use cases or if you require fine-grained control over your logging configuration, the built-in logging module offers more comprehensive features and flexibility. If you are already familiar with the standard logging module, you may not find logEZ to be significantly more helpful.\n\nIn summary, the logEZ library can be useful for developers looking for a simpler and more accessible interface for basic logging tasks. However, it might not offer substantial advantages over the built-in logging module for more experienced users or advanced logging scenarios.\n\n## What's next?\n\nWe have some exciting plans for the future development of logEZ, and we're always looking for ways to make it even more useful for our users. Here's a list of features we're considering adding:\n\n1. Configuration from file support\n2. Log rotation functionality\n3. Support for custom log handlers\n4. Colored console logs\n5. Enhanced context information in log messages\n6. Improved exception handling and logging\n7. Integrated performance metrics\n8. Advanced filtering capabilities\n9. Asynchronous logging support\n10. Better documentation and examples\n\n_We're open to contributions!_ If you'd like to help implement any of these features or have suggestions for improvements, please feel free to reach out to us. You can contact us at [gehlotkunal@outlook.com](mailto:gehlotkunal@outlook.com) or connect with us on Twitter at [@ZackCodesAI](https://twitter.com/ZackCodesAI).\n\nWe're looking forward to collaborating with the community to make logEZ an even more valuable and versatile logging library for Python developers!\n\n\n# Change Log\n\n## Unreleased\n\n## [0.1.0]\n### Updated\n- Refactored the code to adhere to PEP8 standards for better readability and maintainability.\n- Added type hints to function signatures for improved code comprehension and editor support.\n- Improved exception handling with more specific exceptions and error messages.\n- Modularized the code into separate files for better organization and extensibility:\n - `mylogger.py`: Contains the main `MyLogger` class.\n - `handlers.py`: Contains handlers for logging to files and consoles.\n - `formatters.py`: Contains the log formatter used for log messages.\n- Updated the `__init__.py` file to import necessary components for easier library usage.\n- Enhanced the library with docstrings for better documentation and understanding.\n- Updated the `README.md` file to provide clearer instructions on how to use the library, including examples and explanations of the new features.\n- Improved the `setup.py` file to adhere to the latest Python norms and standards.\n- Added `nox` as a development dependency to simplify the development workflow.\n\n## [0.0.3] - 2022-05-08\n### Updated\n- Updated code with method name fix and logging level method.\n- Added \"How to use\" with complete method definition in README.md\n\n## [0.0.2] - 2022-05-08\n### Fixed\n- Fixing project directory name\n\n## [0.0.1] - 2022-05-08\n### Added\n- First Release\n### Removed\n- Removed `requirements.txt`\n- Removed `logging` from `install_requires`\n",
"bugtrack_url": null,
"license": "MIT",
"summary": "A simple(r) logger for Python",
"version": "0.1.0",
"split_keywords": [
"logging"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "07e353aff3adf165197c34ec93c2cb0232a92ffd7ca0644645e8eac3e2a65c65",
"md5": "99ee30cfd14e41add2cf3b59ba972c28",
"sha256": "04db8cc570224e7c84215607817c9e1c9df768e87df11c35b71a96fe3d3ac7d9"
},
"downloads": -1,
"filename": "logEZ-0.1.0-py3-none-any.whl",
"has_sig": false,
"md5_digest": "99ee30cfd14e41add2cf3b59ba972c28",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.8",
"size": 7465,
"upload_time": "2023-03-31T04:47:23",
"upload_time_iso_8601": "2023-03-31T04:47:23.708294Z",
"url": "https://files.pythonhosted.org/packages/07/e3/53aff3adf165197c34ec93c2cb0232a92ffd7ca0644645e8eac3e2a65c65/logEZ-0.1.0-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "d44a1a78fa74a44175bc6e7167d4bf6103c68521712131b883d58ba5f435a100",
"md5": "49084300462928962da7796bdc16739a",
"sha256": "8744802ae309a905fbd60b4b79f4f576de958685d15833f0c6274d0c11e741ce"
},
"downloads": -1,
"filename": "logEZ-0.1.0.tar.gz",
"has_sig": false,
"md5_digest": "49084300462928962da7796bdc16739a",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.8",
"size": 7011567,
"upload_time": "2023-03-31T04:47:30",
"upload_time_iso_8601": "2023-03-31T04:47:30.227490Z",
"url": "https://files.pythonhosted.org/packages/d4/4a/1a78fa74a44175bc6e7167d4bf6103c68521712131b883d58ba5f435a100/logEZ-0.1.0.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2023-03-31 04:47:30",
"github": true,
"gitlab": false,
"bitbucket": false,
"github_user": "KunalGehlot",
"github_project": "logEZ",
"travis_ci": false,
"coveralls": false,
"github_actions": false,
"requirements": [],
"lcname": "logez"
}