py-html-logger


Namepy-html-logger JSON
Version 0.1.4 PyPI version JSON
download
home_pagehttps://github.com/rphpires/py-html-logger
SummaryLibrary for generating HTML logs with support for colors, rotation and filters via JavaScript.
upload_time2025-08-28 15:08:10
maintainerNone
docs_urlNone
authorRaphael Pires
requires_python>=3.8
licenseNone
keywords logging html logger logs colors trace
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # HTML Logger

A Python library for generating HTML logs with support for colors, file rotation, tagging, and JavaScript filters.

## Features

- ✅ Colored logs in HTML format
- ✅ Automatic file rotation
- ✅ Clean interface with integrated JavaScript filters
- ✅ Thread-safe and high performance
- ✅ Exception support with full traceback
- ✅ Flexible configuration for file size and quantity
- ✅ Tagging system for message categorization
- ✅ Advanced filtering by tags and text content

## Installation

```bash
pip install py-html-logger
```

## Basic Usage

```python
from htmllogger import log, error, report_exception

# Simple messages
log("Normal informative message")
log("Blue message", color="blue")

# Error messages
error("This is an error message")

# Log exceptions
try:
    # Your code here
    raise ValueError("Example error")
except Exception as e:
    report_exception(e)
```

## Enhanced Tagging System

The logger supports tagging messages for better organization and filtering:

```python
from htmllogger import log, info, debug, warning

# Simple tagged messages
log("User login", tag="auth")
info("Data processed", tag="processing")
debug("Variable value", tag="debug")
warning("Resource low", tag="system")

# Multiple tags
log("Security event", tag=["security", "monitoring"])
```

## Configuration

```python
from htmllogger import config

# Customize logger settings
config(
    max_files=15,           # Maximum number of log files
    max_size=5000000,       # Maximum size per file (5MB)
    main_filename="log.html", # Main file name
    log_dir="logs"          # Directory for logs
)
```

## File Structure

Logs are stored in the specified directory (default: `logs/`) with the following structure:

```
logs/
└── log.html (current file)
└── 2023-10-05_12-30-45_log.html (rotated file)
└── 2023-10-05_10-15-32_log.html (rotated file)
```

## Integrated JavaScript Filters

Generated HTML files include advanced filtering capabilities to facilitate analysis:

- Text filtering with AND/OR logic
- Tag-based filtering
- Time period filtering
- Real-time highlighting of matched terms
- Preserved original log view

## Complete Example

```python
from htmllogger import log, info, debug, warning, error, report_exception, config

# Configure logger
config(
    max_files=10,
    max_size=2000000,  # 2MB
    log_dir="my_logs"
)

# Log with different tags and levels
log("Application started", tag="system", color="green")
info("Loading configuration", tag="config")
debug("Initializing modules", tag="debug")

for i in range(100):
    if i % 10 == 0:
        log(f"Checkpoint {i}", tag="checkpoint")
    info(f"Processing item {i}", tag="processing")

try:
    # Code that might raise an error
    result = 10 / 0
except Exception as e:
    error("Division by zero detected")
    report_exception(e)

log("Application finished", tag="system", color="green")
```

## API Reference

### log(message, color="white", tag=None)
Logs a message with optional color and tag(s).

### info(message, color="white", tag=None)
Logs an informational message.

### debug(message, color="white", tag=None)
Logs a debug message.

### warning(message, color="gold", tag=None)
Logs a warning message.

### error(message)
Logs an error message (in red).

### report_exception(exc, timeout=None)
Logs an exception with its full traceback.

### config(**kwargs)
Configures logger options:
- `max_files`: Maximum number of files to maintain
- `max_size`: Maximum size in bytes per file
- `main_filename`: Main log file name
- `log_dir`: Directory where logs will be stored

### flush()
Processes all pending messages before termination.

## Development

To contribute to the project:

1. Fork the repository
2. Create your feature branch (`git checkout -b feature/AmazingFeature`)
3. Commit your changes (`git commit -m 'Add some AmazingFeature'`)
4. Push to the branch (`git push origin feature/AmazingFeature`)
5. Open a Pull Request

## Support

If you encounter issues or have questions:

1. Check the [documentation](https://github.com/rphpires/py-html-logger)
2. Open an [issue](https://github.com/rphpires/py-html-logger/issues)
3. Contact: rphspires@gmail.com

## License

This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.

## Acknowledgments

- Developed by Raphael Pires
- Inspired by the need for better log visualization and analysis tools

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/rphpires/py-html-logger",
    "name": "py-html-logger",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.8",
    "maintainer_email": null,
    "keywords": "logging, html, logger, logs, colors, trace",
    "author": "Raphael Pires",
    "author_email": "Raphael Pires Nome <rphspires@gmail.com>",
    "download_url": "https://files.pythonhosted.org/packages/8f/78/1fb2353e983a5224b13128fb3ce9c03d1ac5f539131beda3c02b512cb648/py_html_logger-0.1.4.tar.gz",
    "platform": null,
    "description": "# HTML Logger\r\n\r\nA Python library for generating HTML logs with support for colors, file rotation, tagging, and JavaScript filters.\r\n\r\n## Features\r\n\r\n- \u2705 Colored logs in HTML format\r\n- \u2705 Automatic file rotation\r\n- \u2705 Clean interface with integrated JavaScript filters\r\n- \u2705 Thread-safe and high performance\r\n- \u2705 Exception support with full traceback\r\n- \u2705 Flexible configuration for file size and quantity\r\n- \u2705 Tagging system for message categorization\r\n- \u2705 Advanced filtering by tags and text content\r\n\r\n## Installation\r\n\r\n```bash\r\npip install py-html-logger\r\n```\r\n\r\n## Basic Usage\r\n\r\n```python\r\nfrom htmllogger import log, error, report_exception\r\n\r\n# Simple messages\r\nlog(\"Normal informative message\")\r\nlog(\"Blue message\", color=\"blue\")\r\n\r\n# Error messages\r\nerror(\"This is an error message\")\r\n\r\n# Log exceptions\r\ntry:\r\n    # Your code here\r\n    raise ValueError(\"Example error\")\r\nexcept Exception as e:\r\n    report_exception(e)\r\n```\r\n\r\n## Enhanced Tagging System\r\n\r\nThe logger supports tagging messages for better organization and filtering:\r\n\r\n```python\r\nfrom htmllogger import log, info, debug, warning\r\n\r\n# Simple tagged messages\r\nlog(\"User login\", tag=\"auth\")\r\ninfo(\"Data processed\", tag=\"processing\")\r\ndebug(\"Variable value\", tag=\"debug\")\r\nwarning(\"Resource low\", tag=\"system\")\r\n\r\n# Multiple tags\r\nlog(\"Security event\", tag=[\"security\", \"monitoring\"])\r\n```\r\n\r\n## Configuration\r\n\r\n```python\r\nfrom htmllogger import config\r\n\r\n# Customize logger settings\r\nconfig(\r\n    max_files=15,           # Maximum number of log files\r\n    max_size=5000000,       # Maximum size per file (5MB)\r\n    main_filename=\"log.html\", # Main file name\r\n    log_dir=\"logs\"          # Directory for logs\r\n)\r\n```\r\n\r\n## File Structure\r\n\r\nLogs are stored in the specified directory (default: `logs/`) with the following structure:\r\n\r\n```\r\nlogs/\r\n\u2514\u2500\u2500 log.html (current file)\r\n\u2514\u2500\u2500 2023-10-05_12-30-45_log.html (rotated file)\r\n\u2514\u2500\u2500 2023-10-05_10-15-32_log.html (rotated file)\r\n```\r\n\r\n## Integrated JavaScript Filters\r\n\r\nGenerated HTML files include advanced filtering capabilities to facilitate analysis:\r\n\r\n- Text filtering with AND/OR logic\r\n- Tag-based filtering\r\n- Time period filtering\r\n- Real-time highlighting of matched terms\r\n- Preserved original log view\r\n\r\n## Complete Example\r\n\r\n```python\r\nfrom htmllogger import log, info, debug, warning, error, report_exception, config\r\n\r\n# Configure logger\r\nconfig(\r\n    max_files=10,\r\n    max_size=2000000,  # 2MB\r\n    log_dir=\"my_logs\"\r\n)\r\n\r\n# Log with different tags and levels\r\nlog(\"Application started\", tag=\"system\", color=\"green\")\r\ninfo(\"Loading configuration\", tag=\"config\")\r\ndebug(\"Initializing modules\", tag=\"debug\")\r\n\r\nfor i in range(100):\r\n    if i % 10 == 0:\r\n        log(f\"Checkpoint {i}\", tag=\"checkpoint\")\r\n    info(f\"Processing item {i}\", tag=\"processing\")\r\n\r\ntry:\r\n    # Code that might raise an error\r\n    result = 10 / 0\r\nexcept Exception as e:\r\n    error(\"Division by zero detected\")\r\n    report_exception(e)\r\n\r\nlog(\"Application finished\", tag=\"system\", color=\"green\")\r\n```\r\n\r\n## API Reference\r\n\r\n### log(message, color=\"white\", tag=None)\r\nLogs a message with optional color and tag(s).\r\n\r\n### info(message, color=\"white\", tag=None)\r\nLogs an informational message.\r\n\r\n### debug(message, color=\"white\", tag=None)\r\nLogs a debug message.\r\n\r\n### warning(message, color=\"gold\", tag=None)\r\nLogs a warning message.\r\n\r\n### error(message)\r\nLogs an error message (in red).\r\n\r\n### report_exception(exc, timeout=None)\r\nLogs an exception with its full traceback.\r\n\r\n### config(**kwargs)\r\nConfigures logger options:\r\n- `max_files`: Maximum number of files to maintain\r\n- `max_size`: Maximum size in bytes per file\r\n- `main_filename`: Main log file name\r\n- `log_dir`: Directory where logs will be stored\r\n\r\n### flush()\r\nProcesses all pending messages before termination.\r\n\r\n## Development\r\n\r\nTo contribute to the project:\r\n\r\n1. Fork the repository\r\n2. Create your feature branch (`git checkout -b feature/AmazingFeature`)\r\n3. Commit your changes (`git commit -m 'Add some AmazingFeature'`)\r\n4. Push to the branch (`git push origin feature/AmazingFeature`)\r\n5. Open a Pull Request\r\n\r\n## Support\r\n\r\nIf you encounter issues or have questions:\r\n\r\n1. Check the [documentation](https://github.com/rphpires/py-html-logger)\r\n2. Open an [issue](https://github.com/rphpires/py-html-logger/issues)\r\n3. Contact: rphspires@gmail.com\r\n\r\n## License\r\n\r\nThis project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.\r\n\r\n## Acknowledgments\r\n\r\n- Developed by Raphael Pires\r\n- Inspired by the need for better log visualization and analysis tools\r\n",
    "bugtrack_url": null,
    "license": null,
    "summary": "Library for generating HTML logs with support for colors, rotation and filters via JavaScript.",
    "version": "0.1.4",
    "project_urls": {
        "Bug Tracker": "https://github.com/rphpires/py-html-logger/issues",
        "Homepage": "https://github.com/rphpires/py-html-logger"
    },
    "split_keywords": [
        "logging",
        " html",
        " logger",
        " logs",
        " colors",
        " trace"
    ],
    "urls": [
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "586197e25d9cb78041453f313ba5afaf039ffe6461442eec58ba4c9d3c3eb057",
                "md5": "8f56e68fa58ef9714c63c9dbe56edc32",
                "sha256": "98f90c995c7db3c9dd28eae5c9987a85a22febd2f7a4fe471730505a29a8e1ce"
            },
            "downloads": -1,
            "filename": "py_html_logger-0.1.4-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "8f56e68fa58ef9714c63c9dbe56edc32",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.8",
            "size": 11375,
            "upload_time": "2025-08-28T15:08:08",
            "upload_time_iso_8601": "2025-08-28T15:08:08.787222Z",
            "url": "https://files.pythonhosted.org/packages/58/61/97e25d9cb78041453f313ba5afaf039ffe6461442eec58ba4c9d3c3eb057/py_html_logger-0.1.4-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "8f781fb2353e983a5224b13128fb3ce9c03d1ac5f539131beda3c02b512cb648",
                "md5": "63e8f07102c859b86c138beccf00b6e6",
                "sha256": "ea2335b3ffe3579a90287be5093fc36dfe426e238d07972a5a0712e31e47ccec"
            },
            "downloads": -1,
            "filename": "py_html_logger-0.1.4.tar.gz",
            "has_sig": false,
            "md5_digest": "63e8f07102c859b86c138beccf00b6e6",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.8",
            "size": 13376,
            "upload_time": "2025-08-28T15:08:10",
            "upload_time_iso_8601": "2025-08-28T15:08:10.016706Z",
            "url": "https://files.pythonhosted.org/packages/8f/78/1fb2353e983a5224b13128fb3ce9c03d1ac5f539131beda3c02b512cb648/py_html_logger-0.1.4.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2025-08-28 15:08:10",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "rphpires",
    "github_project": "py-html-logger",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "lcname": "py-html-logger"
}
        
Elapsed time: 1.30171s