# Pro Logging
**Pro Logging** is an advanced, fully customizable logging package for Python projects. It allows developers to log their application's processes to both a log file and an optional database. This package supports various features such as log rotation, different log levels, JSON format logging, and database storage.
## Features
- **Log Levels**: DEBUG, INFO, WARNING, ERROR, CRITICAL
- **Log Rotation**: Supports both file size-based and date-based log rotation
- **JSON Format**: Option to log messages in JSON format
- **Database Logging**: Store logs in an SQLite database for easier management and analysis
- **Console Output**: Print log messages to the console
- **Customization**: Users can configure log file name, log levels, rotation settings, and more
## Installation
Install the package using pip:
```bash
pip install pro-logging
```
## Usage
Here's a basic example of how to use the pro-logging package:
```python
from pro_logging import AdvancedLogger
# Initialize the logger
logger = AdvancedLogger(
log_filename='app.log', # Log file name
level="DEBUG", # Log level
log_to_console=True, # Output to console
rotate_logs=True, # Enable log rotation
max_size_mb=10, # Maximum log file size before rotation
json_format=True, # Log in JSON format
db_path='app_logs.db' # Path to the SQLite database for logs
)
# Log some messages
logger.log_info("This is an informational message.")
logger.log_error("This is an error message.")
logger.log_debug("This is a debug message.")
```
## Example
Logging with Different Levels
```python
logger.log_debug("Debugging the application")
logger.log_info("Application is running")
logger.log_warning("This is a warning")
logger.log_error("An error occurred")
logger.log_critical("Critical system failure")
```
## Log Rotation
You can rotate logs based on file size or date.
```python
# Enable file size-based log rotation
logger = AdvancedLogger(rotate_logs=True, max_size_mb=5)
# Enable date-based log rotation
logger = AdvancedLogger(date_based_rotation=True)
```
## Database Logging
Logs can also be stored in an SQLite database for further analysis.
```python
logger = AdvancedLogger(db_path='app_logs.db')
# Log messages will be saved in the database
logger.log_info("This log is saved in the database as well.")
```
## Customization
You can adjust log settings such as file name, log level, JSON formatting, and more:
```python
logger = AdvancedLogger(
log_filename='custom.log',
level="WARNING",
json_format=True
)
```
Raw data
{
"_id": null,
"home_page": "https://github.com/mjavadhe/arduinopy",
"name": "pro-logging",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3.6",
"maintainer_email": null,
"keywords": null,
"author": "Mohamadjavad Heydarpanah",
"author_email": "mjavad.heydarpanah@gmail.com",
"download_url": "https://files.pythonhosted.org/packages/b9/ee/54a2ba2e902333f33548bfe2f7cacdb4a3c00d3e2c7e0dbcb3343a3a7c32/pro-logging-1.0.0.tar.gz",
"platform": null,
"description": "# Pro Logging\r\n\r\n**Pro Logging** is an advanced, fully customizable logging package for Python projects. It allows developers to log their application's processes to both a log file and an optional database. This package supports various features such as log rotation, different log levels, JSON format logging, and database storage.\r\n\r\n## Features\r\n\r\n- **Log Levels**: DEBUG, INFO, WARNING, ERROR, CRITICAL\r\n- **Log Rotation**: Supports both file size-based and date-based log rotation\r\n- **JSON Format**: Option to log messages in JSON format\r\n- **Database Logging**: Store logs in an SQLite database for easier management and analysis\r\n- **Console Output**: Print log messages to the console\r\n- **Customization**: Users can configure log file name, log levels, rotation settings, and more\r\n\r\n## Installation\r\n\r\nInstall the package using pip:\r\n\r\n```bash\r\npip install pro-logging\r\n```\r\n\r\n## Usage\r\n\r\nHere's a basic example of how to use the pro-logging package:\r\n\r\n```python\r\nfrom pro_logging import AdvancedLogger\r\n\r\n# Initialize the logger\r\nlogger = AdvancedLogger(\r\n log_filename='app.log', # Log file name\r\n level=\"DEBUG\", # Log level\r\n log_to_console=True, # Output to console\r\n rotate_logs=True, # Enable log rotation\r\n max_size_mb=10, # Maximum log file size before rotation\r\n json_format=True, # Log in JSON format\r\n db_path='app_logs.db' # Path to the SQLite database for logs\r\n)\r\n\r\n# Log some messages\r\nlogger.log_info(\"This is an informational message.\")\r\nlogger.log_error(\"This is an error message.\")\r\nlogger.log_debug(\"This is a debug message.\")\r\n```\r\n\r\n## Example\r\n\r\nLogging with Different Levels\r\n\r\n```python\r\nlogger.log_debug(\"Debugging the application\")\r\nlogger.log_info(\"Application is running\")\r\nlogger.log_warning(\"This is a warning\")\r\nlogger.log_error(\"An error occurred\")\r\nlogger.log_critical(\"Critical system failure\")\r\n```\r\n\r\n## Log Rotation\r\n\r\nYou can rotate logs based on file size or date.\r\n\r\n```python\r\n# Enable file size-based log rotation\r\nlogger = AdvancedLogger(rotate_logs=True, max_size_mb=5)\r\n\r\n# Enable date-based log rotation\r\nlogger = AdvancedLogger(date_based_rotation=True)\r\n```\r\n\r\n## Database Logging\r\n\r\nLogs can also be stored in an SQLite database for further analysis.\r\n\r\n```python\r\nlogger = AdvancedLogger(db_path='app_logs.db')\r\n\r\n# Log messages will be saved in the database\r\nlogger.log_info(\"This log is saved in the database as well.\")\r\n```\r\n\r\n## Customization\r\n\r\nYou can adjust log settings such as file name, log level, JSON formatting, and more:\r\n\r\n```python\r\nlogger = AdvancedLogger(\r\n log_filename='custom.log',\r\n level=\"WARNING\",\r\n json_format=True\r\n)\r\n```\r\n",
"bugtrack_url": null,
"license": null,
"summary": "An advanced logging package for Python projects",
"version": "1.0.0",
"project_urls": {
"Homepage": "https://github.com/mjavadhe/arduinopy"
},
"split_keywords": [],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "cca69f25a6cd81f5d34d706d433541fc3655bc396b3f5ac32dfea3504b0a9495",
"md5": "b71f1b0e7ff75323a7606627790a376c",
"sha256": "248fa070d1d54c6848c23a6521bc7738e399cb8c41a0afb948ca0520f18c2de1"
},
"downloads": -1,
"filename": "pro_logging-1.0.0-py3-none-any.whl",
"has_sig": false,
"md5_digest": "b71f1b0e7ff75323a7606627790a376c",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.6",
"size": 4182,
"upload_time": "2024-10-13T06:23:46",
"upload_time_iso_8601": "2024-10-13T06:23:46.970334Z",
"url": "https://files.pythonhosted.org/packages/cc/a6/9f25a6cd81f5d34d706d433541fc3655bc396b3f5ac32dfea3504b0a9495/pro_logging-1.0.0-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "b9ee54a2ba2e902333f33548bfe2f7cacdb4a3c00d3e2c7e0dbcb3343a3a7c32",
"md5": "8b2e4bd67c6a3e85bee4e937f8318156",
"sha256": "d9a9707bf4d5de00ab17d6df0c7fef847e6a792339445d2116b91454eafd2169"
},
"downloads": -1,
"filename": "pro-logging-1.0.0.tar.gz",
"has_sig": false,
"md5_digest": "8b2e4bd67c6a3e85bee4e937f8318156",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.6",
"size": 3887,
"upload_time": "2024-10-13T06:23:48",
"upload_time_iso_8601": "2024-10-13T06:23:48.661607Z",
"url": "https://files.pythonhosted.org/packages/b9/ee/54a2ba2e902333f33548bfe2f7cacdb4a3c00d3e2c7e0dbcb3343a3a7c32/pro-logging-1.0.0.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-10-13 06:23:48",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "mjavadhe",
"github_project": "arduinopy",
"github_not_found": true,
"lcname": "pro-logging"
}