DetailLogger


NameDetailLogger JSON
Version 0.1.4 PyPI version JSON
download
home_pagehttps://github.com/rlapine/DetailLogger
SummaryStyled console printing made simple β€” color, format, and clarity in one package.
upload_time2025-07-30 22:16:15
maintainerNone
docs_urlNone
authorRyan LaPine
requires_python>=3.7
licenseMIT
keywords
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            <p align="center">
  <img src="https://raw.githubusercontent.com/rlapine/detaillogger/refs/heads/main/assets/detaillogger_logo_2.png" alt="DetailLogger logo" width="400"/>
</p>

---

## 🎨 DetailLogger V 0.1.4

---

[![Python](https://img.shields.io/badge/python-3.10%2B-blue)](https://www.python.org/downloads/)
[![License](https://img.shields.io/badge/license-MIT-green)](LICENSE)
[![GitHub Stars](https://img.shields.io/github/stars/rlapine/detaillogger?style=social)](https://github.com/rlapine/detaillogger/stargazers)
[![GitHub Forks](https://img.shields.io/github/forks/rlapine/detaillogger?style=social)](https://github.com/rlapine/detaillogger/network/members)

---

## ✨ Overview

DetailLogger is a lightweight Python utility for enhanced logging and exception tracing. It automatically captures contextual informationβ€”such as file name, function, and line numberβ€”whenever messages or exceptions are logged. Ideal for debugging, monitoring, and building maintainable systems.

---

## πŸ“¦ Installation

`pip install detaillogger`

---

## βš™οΈ Features

- βœ… Logs messages with caller context  
- βœ… Captures exceptions with full traceback  
- βœ… Supports console and file-based logging  
- βœ… Uses wrapper functions for quick integration  
- βœ… Built entirely on standard libraries

---

## ✍️ API Overview

- `DetailLogger(level, fmt, file_name)`: Create an instance with optional file output and log level  
- `log(message: str)`: Logs message with caller metadata  
- `log_exception(ex: BaseException, details: Optional[str])`: Logs exception type, message, optional details, and source context

---

## πŸ§ͺ Usage

# Run the built-in CLI demo for testing:

`python detaillogger.py`

# Embedded Example

```
from detaillogger import log, log_exception

log("This is a message to log.")

try:
    x = 1 / 0
except Exception as e:
    log_exception(e, details="This is a message about the exception to log.")
```

**Console Output:**

```
2025-07-28 17:02:27,674 - DEBUG - Details:  This is a message to log.
2025-07-28 17:02:27,674 - DEBUG - From:     c:\Users\ryan\...detaillogger.py
2025-07-28 17:02:27,675 - DEBUG - Function: main()
2025-07-28 17:02:27,675 - DEBUG - Line:     3

2025-07-28 17:05:22,185 - DEBUG - Exception type:    ZeroDivisionError
2025-07-28 17:05:22,186 - DEBUG - Exception message: division by zero
2025-07-28 17:05:22,186 - DEBUG - Details:           This is a message about the exception to log.
2025-07-28 17:05:22,186 - DEBUG - File:              ...detaillogger.py
2025-07-28 17:05:22,186 - DEBUG - Function:          main()
2025-07-28 17:05:22,186 - DEBUG - Line:              6
```

# Embedded Example

```
# To log to a file and console, instantiate DetailLogger class with filename.
from detaillogger import log, log_exception

logger = DetailLogger(file_name="detail.log")

log("This is a message to log to file.")

try:
    x = 1 / 0
except Exception as e:
    log_exception(e, details="This is a message about the exception to log to file.")
```

**File Output:**

![detail.log](https://raw.githubusercontent.com/rlapine/detaillogger/main/assets/image.png)

---

## πŸ”§ Built-in demo:

`python detaillogger.py`

```
Also log to file? (y/n):y
Enter filname:detail.log

Options
1) Log details.
2) Log 'division by zero' exception.
3) Log custom exception.
q) Exit.
Enter an option:1

Enter message to log:This is a message.
2025-07-30 14:46:04,161 - DEBUG - Details:  This is a message.
2025-07-30 14:46:04,161 - DEBUG - From:     c:\Users\ryan\Visual Code Projects\git_repositories\detaillogger\detaillogger.py
2025-07-30 14:46:04,162 - DEBUG - Function: main()
2025-07-30 14:46:04,162 - DEBUG - Line:     179

Message logged.
```

---

## 🧱 File Structure

```
detaillogger/
β”œβ”€β”€ detaillogger.py         # Core module
β”œβ”€β”€ test_detaillogger.py    # Unit test suite
β”œβ”€β”€ assets/                 # Folder for images, badges, or other static assets
β”‚   β”œβ”€β”€ detaillogger_logo_2.png     # Logo for documentation
β”‚   └── image.png                   # File output 
β”œβ”€β”€ README.md             # Documentation
β”œβ”€β”€ detaillogger.log      # Optional output log file
```

---

## 🀝 Contributing

Pull requests are welcome! For major changes, open an issue to discuss improvements first.

---

## πŸ“„ License

This project is licensed under the [MIT License](LICENSE).

---

## πŸ‘€ Author

Created by Ryan LaPine [@rlapine](https://github.com/rlapine) β€” a technically skilled developer focused on clarity, maintainability, and audience-ready documentation. This class is part of a broader effort to build reusable, well-documented tools for data-driven projects.

---

## πŸ“¬ Contact

Feel free to reach out with questions or collaboration ideas:

πŸ“§ github.stunt845@passinbox.com  
πŸ”— GitHub: [@rlapine](https://github.com/rlapine)

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/rlapine/DetailLogger",
    "name": "DetailLogger",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.7",
    "maintainer_email": null,
    "keywords": null,
    "author": "Ryan LaPine",
    "author_email": "github.stunt845@passinbox.com",
    "download_url": "https://files.pythonhosted.org/packages/7a/6b/aea07dae7a66d4c55ffcd188a2e08a7f181bdf92314209b2227df08606eb/detaillogger-0.1.4.tar.gz",
    "platform": null,
    "description": "<p align=\"center\">\r\n  <img src=\"https://raw.githubusercontent.com/rlapine/detaillogger/refs/heads/main/assets/detaillogger_logo_2.png\" alt=\"DetailLogger logo\" width=\"400\"/>\r\n</p>\r\n\r\n---\r\n\r\n## \ud83c\udfa8 DetailLogger V 0.1.4\r\n\r\n---\r\n\r\n[![Python](https://img.shields.io/badge/python-3.10%2B-blue)](https://www.python.org/downloads/)\r\n[![License](https://img.shields.io/badge/license-MIT-green)](LICENSE)\r\n[![GitHub Stars](https://img.shields.io/github/stars/rlapine/detaillogger?style=social)](https://github.com/rlapine/detaillogger/stargazers)\r\n[![GitHub Forks](https://img.shields.io/github/forks/rlapine/detaillogger?style=social)](https://github.com/rlapine/detaillogger/network/members)\r\n\r\n---\r\n\r\n## \u2728 Overview\r\n\r\nDetailLogger is a lightweight Python utility for enhanced logging and exception tracing. It automatically captures contextual information\u2014such as file name, function, and line number\u2014whenever messages or exceptions are logged. Ideal for debugging, monitoring, and building maintainable systems.\r\n\r\n---\r\n\r\n## \ud83d\udce6 Installation\r\n\r\n`pip install detaillogger`\r\n\r\n---\r\n\r\n## \u2699\ufe0f Features\r\n\r\n- \u2705 Logs messages with caller context  \r\n- \u2705 Captures exceptions with full traceback  \r\n- \u2705 Supports console and file-based logging  \r\n- \u2705 Uses wrapper functions for quick integration  \r\n- \u2705 Built entirely on standard libraries\r\n\r\n---\r\n\r\n## \u270d\ufe0f API Overview\r\n\r\n- `DetailLogger(level, fmt, file_name)`: Create an instance with optional file output and log level  \r\n- `log(message: str)`: Logs message with caller metadata  \r\n- `log_exception(ex: BaseException, details: Optional[str])`: Logs exception type, message, optional details, and source context\r\n\r\n---\r\n\r\n## \ud83e\uddea Usage\r\n\r\n# Run the built-in CLI demo for testing:\r\n\r\n`python detaillogger.py`\r\n\r\n# Embedded Example\r\n\r\n```\r\nfrom detaillogger import log, log_exception\r\n\r\nlog(\"This is a message to log.\")\r\n\r\ntry:\r\n    x = 1 / 0\r\nexcept Exception as e:\r\n    log_exception(e, details=\"This is a message about the exception to log.\")\r\n```\r\n\r\n**Console Output:**\r\n\r\n```\r\n2025-07-28 17:02:27,674 - DEBUG - Details:  This is a message to log.\r\n2025-07-28 17:02:27,674 - DEBUG - From:     c:\\Users\\ryan\\...detaillogger.py\r\n2025-07-28 17:02:27,675 - DEBUG - Function: main()\r\n2025-07-28 17:02:27,675 - DEBUG - Line:     3\r\n\r\n2025-07-28 17:05:22,185 - DEBUG - Exception type:    ZeroDivisionError\r\n2025-07-28 17:05:22,186 - DEBUG - Exception message: division by zero\r\n2025-07-28 17:05:22,186 - DEBUG - Details:           This is a message about the exception to log.\r\n2025-07-28 17:05:22,186 - DEBUG - File:              ...detaillogger.py\r\n2025-07-28 17:05:22,186 - DEBUG - Function:          main()\r\n2025-07-28 17:05:22,186 - DEBUG - Line:              6\r\n```\r\n\r\n# Embedded Example\r\n\r\n```\r\n# To log to a file and console, instantiate DetailLogger class with filename.\r\nfrom detaillogger import log, log_exception\r\n\r\nlogger = DetailLogger(file_name=\"detail.log\")\r\n\r\nlog(\"This is a message to log to file.\")\r\n\r\ntry:\r\n    x = 1 / 0\r\nexcept Exception as e:\r\n    log_exception(e, details=\"This is a message about the exception to log to file.\")\r\n```\r\n\r\n**File Output:**\r\n\r\n![detail.log](https://raw.githubusercontent.com/rlapine/detaillogger/main/assets/image.png)\r\n\r\n---\r\n\r\n## \ud83d\udd27 Built-in demo:\r\n\r\n`python detaillogger.py`\r\n\r\n```\r\nAlso log to file? (y/n):y\r\nEnter filname:detail.log\r\n\r\nOptions\r\n1) Log details.\r\n2) Log 'division by zero' exception.\r\n3) Log custom exception.\r\nq) Exit.\r\nEnter an option:1\r\n\r\nEnter message to log:This is a message.\r\n2025-07-30 14:46:04,161 - DEBUG - Details:  This is a message.\r\n2025-07-30 14:46:04,161 - DEBUG - From:     c:\\Users\\ryan\\Visual Code Projects\\git_repositories\\detaillogger\\detaillogger.py\r\n2025-07-30 14:46:04,162 - DEBUG - Function: main()\r\n2025-07-30 14:46:04,162 - DEBUG - Line:     179\r\n\r\nMessage logged.\r\n```\r\n\r\n---\r\n\r\n## \ud83e\uddf1 File Structure\r\n\r\n```\r\ndetaillogger/\r\n\u251c\u2500\u2500 detaillogger.py         # Core module\r\n\u251c\u2500\u2500 test_detaillogger.py    # Unit test suite\r\n\u251c\u2500\u2500 assets/                 # Folder for images, badges, or other static assets\r\n\u2502   \u251c\u2500\u2500 detaillogger_logo_2.png     # Logo for documentation\r\n\u2502   \u2514\u2500\u2500 image.png                   # File output \r\n\u251c\u2500\u2500 README.md             # Documentation\r\n\u251c\u2500\u2500 detaillogger.log      # Optional output log file\r\n```\r\n\r\n---\r\n\r\n## \ud83e\udd1d Contributing\r\n\r\nPull requests are welcome! For major changes, open an issue to discuss improvements first.\r\n\r\n---\r\n\r\n## \ud83d\udcc4 License\r\n\r\nThis project is licensed under the [MIT License](LICENSE).\r\n\r\n---\r\n\r\n## \ud83d\udc64 Author\r\n\r\nCreated by Ryan LaPine [@rlapine](https://github.com/rlapine) \u2014 a technically skilled developer focused on clarity, maintainability, and audience-ready documentation. This class is part of a broader effort to build reusable, well-documented tools for data-driven projects.\r\n\r\n---\r\n\r\n## \ud83d\udcec Contact\r\n\r\nFeel free to reach out with questions or collaboration ideas:\r\n\r\n\ud83d\udce7 github.stunt845@passinbox.com  \r\n\ud83d\udd17 GitHub: [@rlapine](https://github.com/rlapine)\r\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "Styled console printing made simple \u2014 color, format, and clarity in one package.",
    "version": "0.1.4",
    "project_urls": {
        "Homepage": "https://github.com/rlapine/DetailLogger"
    },
    "split_keywords": [],
    "urls": [
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "f839328513798545bb2038b85fc380f512ed6b7f5c0bca8fe603b6e25f041daa",
                "md5": "fc49141419dcd86a235f8dc6daecbe9d",
                "sha256": "c714e52913f7cbd122417778b1d724ab0809da48b99293bdcd098261d3017de4"
            },
            "downloads": -1,
            "filename": "detaillogger-0.1.4-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "fc49141419dcd86a235f8dc6daecbe9d",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.7",
            "size": 4267,
            "upload_time": "2025-07-30T22:16:13",
            "upload_time_iso_8601": "2025-07-30T22:16:13.950759Z",
            "url": "https://files.pythonhosted.org/packages/f8/39/328513798545bb2038b85fc380f512ed6b7f5c0bca8fe603b6e25f041daa/detaillogger-0.1.4-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "7a6baea07dae7a66d4c55ffcd188a2e08a7f181bdf92314209b2227df08606eb",
                "md5": "19b61954f793a98467186d6179271a10",
                "sha256": "ed45065834b50f15d421b1251781e8fa4c1ae95db99163d317a80d8dc497812a"
            },
            "downloads": -1,
            "filename": "detaillogger-0.1.4.tar.gz",
            "has_sig": false,
            "md5_digest": "19b61954f793a98467186d6179271a10",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.7",
            "size": 4053,
            "upload_time": "2025-07-30T22:16:15",
            "upload_time_iso_8601": "2025-07-30T22:16:15.066301Z",
            "url": "https://files.pythonhosted.org/packages/7a/6b/aea07dae7a66d4c55ffcd188a2e08a7f181bdf92314209b2227df08606eb/detaillogger-0.1.4.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2025-07-30 22:16:15",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "rlapine",
    "github_project": "DetailLogger",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "lcname": "detaillogger"
}
        
Elapsed time: 2.57496s