printinglog


Nameprintinglog JSON
Version 0.0.1 PyPI version JSON
download
home_pageNone
SummaryPython logging instead of complicated print
upload_time2024-07-26 21:27:17
maintainerNone
docs_urlNone
authorNone
requires_python>=3.9
licenseNone
keywords log logger logging loguru
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # Simple Logging Module

I've been using pythons built-in logging for my previous projects, but i discovered that it doesn't work as expected when running cronjobs in docker containers. The logger fails to write to the specified file because cronjobs operate in a limited environment with different permissions. They often capture standard output and error to a default file, usually ```cron.log``` in my case. While there might be ways to fix this, as a coder, it feels much better to write my own logging module; it would be a disgrace otherwise. So with this module, i can read the logs from cron.log since it uses print statements with logging formatting.

### Install
Install the module with:
```bash
pip install printinglog
```

### Usage
To start using `printinglog`, initialize the logger with:
```python
from printinglog import Logger

logger = Logger()

logger.info("This is a INFO log")
```

You can also change how much detail you want to show in your log:
```python
logger = Logger(format="simple")
logger.info("This is a INFO log")
>> INFO: This is a INFO log

logger = Logger(format="logging")
logger.info("This is a INFO log")
>> 2024-07-26 22:55:28 - INFO: This is a INFO log

logger = Logger(format="detailed")
logger.info("This is a INFO log")
>> 2024-07-26 22:55:28 @main - INFO: This is a INFO log

logger = Logger(format="long")
logger.info("This is a INFO log")
>> INFO: This is a INFO log
2024-07-26 22:55:28 @main<test_function> - INFO: This is a INFO log
```

To change the colors for each log type, you can also specify that:
```python
default_colors = {
    "info": "green",
    "error": "red",
    "warning": "yellow",
    "debug": "blue",
}
logger = Logger(colorscheme=default_colors)
```

Colors to choose from:
* black
* red
* green
* yellow
* blue
* magneta
* cyan
* white


            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "printinglog",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.9",
    "maintainer_email": null,
    "keywords": "log, logger, logging, loguru",
    "author": null,
    "author_email": "Tahko <tahkodev@gmail.com>",
    "download_url": "https://files.pythonhosted.org/packages/6e/cb/9fc9b9d4baa7a7d9c0c578c23a2c85ff12f7a412cf1dd3596e3e379430bd/printinglog-0.0.1.tar.gz",
    "platform": null,
    "description": "# Simple Logging Module\n\nI've been using pythons built-in logging for my previous projects, but i discovered that it doesn't work as expected when running cronjobs in docker containers. The logger fails to write to the specified file because cronjobs operate in a limited environment with different permissions. They often capture standard output and error to a default file, usually ```cron.log``` in my case. While there might be ways to fix this, as a coder, it feels much better to write my own logging module; it would be a disgrace otherwise. So with this module, i can read the logs from cron.log since it uses print statements with logging formatting.\n\n### Install\nInstall the module with:\n```bash\npip install printinglog\n```\n\n### Usage\nTo start using `printinglog`, initialize the logger with:\n```python\nfrom printinglog import Logger\n\nlogger = Logger()\n\nlogger.info(\"This is a INFO log\")\n```\n\nYou can also change how much detail you want to show in your log:\n```python\nlogger = Logger(format=\"simple\")\nlogger.info(\"This is a INFO log\")\n>> INFO: This is a INFO log\n\nlogger = Logger(format=\"logging\")\nlogger.info(\"This is a INFO log\")\n>> 2024-07-26 22:55:28 - INFO: This is a INFO log\n\nlogger = Logger(format=\"detailed\")\nlogger.info(\"This is a INFO log\")\n>> 2024-07-26 22:55:28 @main - INFO: This is a INFO log\n\nlogger = Logger(format=\"long\")\nlogger.info(\"This is a INFO log\")\n>> INFO: This is a INFO log\n2024-07-26 22:55:28 @main<test_function> - INFO: This is a INFO log\n```\n\nTo change the colors for each log type, you can also specify that:\n```python\ndefault_colors = {\n    \"info\": \"green\",\n    \"error\": \"red\",\n    \"warning\": \"yellow\",\n    \"debug\": \"blue\",\n}\nlogger = Logger(colorscheme=default_colors)\n```\n\nColors to choose from:\n* black\n* red\n* green\n* yellow\n* blue\n* magneta\n* cyan\n* white\n\n",
    "bugtrack_url": null,
    "license": null,
    "summary": "Python logging instead of complicated print",
    "version": "0.0.1",
    "project_urls": {
        "Homepage": "https://github.com/danjeltahko/printinglog",
        "Issues": "https://github.com/danjeltahko/printinglog/issues"
    },
    "split_keywords": [
        "log",
        " logger",
        " logging",
        " loguru"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "e00c75b39a6e44757f3692733987f6a6f2b11b0b7d0774663d8c0b160e67959a",
                "md5": "958bf5cefac8058d807ccb847aeb92b7",
                "sha256": "558bdb47225c42d898f5fdf8bf04f4120f9ead51e8fe9af548c07b3187b8f41e"
            },
            "downloads": -1,
            "filename": "printinglog-0.0.1-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "958bf5cefac8058d807ccb847aeb92b7",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.9",
            "size": 4254,
            "upload_time": "2024-07-26T21:27:16",
            "upload_time_iso_8601": "2024-07-26T21:27:16.158463Z",
            "url": "https://files.pythonhosted.org/packages/e0/0c/75b39a6e44757f3692733987f6a6f2b11b0b7d0774663d8c0b160e67959a/printinglog-0.0.1-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "6ecb9fc9b9d4baa7a7d9c0c578c23a2c85ff12f7a412cf1dd3596e3e379430bd",
                "md5": "35c74459903b4ca7c95be852dffed8c8",
                "sha256": "b238fbec7460df6991a2218b0f9505476b4ef2eaa24e987c668dc1fe930053bd"
            },
            "downloads": -1,
            "filename": "printinglog-0.0.1.tar.gz",
            "has_sig": false,
            "md5_digest": "35c74459903b4ca7c95be852dffed8c8",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.9",
            "size": 3575,
            "upload_time": "2024-07-26T21:27:17",
            "upload_time_iso_8601": "2024-07-26T21:27:17.854618Z",
            "url": "https://files.pythonhosted.org/packages/6e/cb/9fc9b9d4baa7a7d9c0c578c23a2c85ff12f7a412cf1dd3596e3e379430bd/printinglog-0.0.1.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-07-26 21:27:17",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "danjeltahko",
    "github_project": "printinglog",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "lcname": "printinglog"
}
        
Elapsed time: 1.24786s