logger-color


Namelogger-color JSON
Version 0.1.0 PyPI version JSON
download
home_pagehttps://github.com/vladimirs-git/logger-color
SummaryColor the log message headers and add more logging levels for diagnostics.
upload_time2024-10-19 08:21:27
maintainerNone
docs_urlNone
authorVladimirs Prusakovs
requires_python<4.0,>=3.8
licenseApache-2.0
keywords logging logger color
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            
.. image:: https://img.shields.io/pypi/v/logger-color.svg
   :target: https://pypi.python.org/pypi/logger-color
.. image:: https://img.shields.io/pypi/pyversions/logger-color.svg
   :target: https://pypi.python.org/pypi/logger-color

logger-color
============

Color the log message headers and add more logging levels for diagnostics: DIAG_INFO, DIAG_WARNING.

============== ===== ===========
Level          Int   Color
============== ===== ===========
DEBUG          10    gray
INFO           20    green
WARNING        30    yellow
ERROR          40    red
CRITICAL       50    bold red
DIAG_INFO      21    blue
DIAG_WARNING   31    purple
============== ===== ===========

.. image:: https://github.com/vladimirs-git/logger-color/blob/main/docs/img/message_colors.png
   :alt: Message colors


Requirements
------------

Python >=3.8,<3.12


Installation
------------

Install the package from pypi.org release

.. code:: bash

    pip install logger-color

or install the package from github.com repository

.. code:: bash

    pip install git+https://github.com/vladimirs-git/logger-color


start_logging()
---------------
**start_logging(filename, mode, level, level_file, color, debug)** - Start logging
with the specified parameters


Parameters
----------

=========== ======= ======= ============================================================================================
Parameter   Type    Default Description
=========== ======= ======= ============================================================================================
filename    *str*           Writes messages to this file. By default, logging only to the terminal
mode        *str*   "w"     "w" - Writes to file (default), "a" - Appends to file
level       *str*   INFO    Logging level for the terminal: "DEBUG", "INFO" (default), "WARNING", "ERROR", "CRITICAL", "DIAG_INFO", "DIAG_WARNING"
level_file  *str*   level   Logging level for the file. By default, the same as `level` parameter
color       *bool*  True    True  - Prints a colored message to the terminal (default), False - Prints a monochrome message to the terminal
debug       *bool*  False   True  - Sets logging level to DEBUG (rewrites `level` parameter), works the same as level="DEBUG". False - Gets logging level from `level` parameter (default)
=========== ======= ======= ============================================================================================


debug()
-------
**debug(args, kwargs)** - Log a message with severity "DEBUG"


diag_info()
-----------
**diag_info(msg, args, kwargs)** - Log diagnostic message with severity "INFO"


diag_warning()
--------------
**diag_warning(msg, args, kwargs)** - Log diagnostic message with severity "WARNING"


info()
------
**info(args, kwargs)** - Log a message with severity "INFO"


warning()
---------
**warning(args, kwargs)** - Log a message with severity "WARNING"


error()
-------
**error(args, kwargs)** - Log a message with severity "ERROR"


critical()
----------
**warning(args, kwargs)** - Log a message with severity "CRITICAL"


**Example**

.. code:: python

    import logger_color

    logger_color.start_logging(filename="/var/log/test.log", level="debug", level_file="error")
    logger_color.debug("debug")
    logger_color.info("info")
    logger_color.warning("warning")
    logger_color.error("error")
    logger_color.critical("critical")
    logger_color.diag_info("diag_info")
    logger_color.diag_warning("diag_warning")
    # 2024-10-19 11:03:25.691 DEBUG    functions.debug: debug
    # 2024-10-19 11:03:25.691 INFO     functions.info: info
    # 2024-10-19 11:03:25.691 WARNING  functions.warning: warning
    # 2024-10-19 11:03:25.691 ERROR    functions.error: error
    # 2024-10-19 11:03:25.691 CRITICAL functions.critical: critical
    # 2024-10-19 11:03:25.691 DIAG_I   examples_messages.<module>: diag_info
    # 2024-10-19 11:03:25.691 DIAG_W   examples_messages.<module>: diag_warning

    # cat /var/log/test.log
    # 2024-10-19 11:03:25 ERROR    error
    # 2024-10-19 11:03:25 CRITICAL critical


            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/vladimirs-git/logger-color",
    "name": "logger-color",
    "maintainer": null,
    "docs_url": null,
    "requires_python": "<4.0,>=3.8",
    "maintainer_email": null,
    "keywords": "logging, logger, color",
    "author": "Vladimirs Prusakovs",
    "author_email": "vladimir.prusakovs@gmail.com",
    "download_url": "https://files.pythonhosted.org/packages/eb/15/d6a21d7c22705eececd2505351a6fafeb60d5352c02bd66e4726ecbfa0d3/logger_color-0.1.0.tar.gz",
    "platform": null,
    "description": "\n.. image:: https://img.shields.io/pypi/v/logger-color.svg\n   :target: https://pypi.python.org/pypi/logger-color\n.. image:: https://img.shields.io/pypi/pyversions/logger-color.svg\n   :target: https://pypi.python.org/pypi/logger-color\n\nlogger-color\n============\n\nColor the log message headers and add more logging levels for diagnostics: DIAG_INFO, DIAG_WARNING.\n\n============== ===== ===========\nLevel          Int   Color\n============== ===== ===========\nDEBUG          10    gray\nINFO           20    green\nWARNING        30    yellow\nERROR          40    red\nCRITICAL       50    bold red\nDIAG_INFO      21    blue\nDIAG_WARNING   31    purple\n============== ===== ===========\n\n.. image:: https://github.com/vladimirs-git/logger-color/blob/main/docs/img/message_colors.png\n   :alt: Message colors\n\n\nRequirements\n------------\n\nPython >=3.8,<3.12\n\n\nInstallation\n------------\n\nInstall the package from pypi.org release\n\n.. code:: bash\n\n    pip install logger-color\n\nor install the package from github.com repository\n\n.. code:: bash\n\n    pip install git+https://github.com/vladimirs-git/logger-color\n\n\nstart_logging()\n---------------\n**start_logging(filename, mode, level, level_file, color, debug)** - Start logging\nwith the specified parameters\n\n\nParameters\n----------\n\n=========== ======= ======= ============================================================================================\nParameter   Type    Default Description\n=========== ======= ======= ============================================================================================\nfilename    *str*           Writes messages to this file. By default, logging only to the terminal\nmode        *str*   \"w\"     \"w\" - Writes to file (default), \"a\" - Appends to file\nlevel       *str*   INFO    Logging level for the terminal: \"DEBUG\", \"INFO\" (default), \"WARNING\", \"ERROR\", \"CRITICAL\", \"DIAG_INFO\", \"DIAG_WARNING\"\nlevel_file  *str*   level   Logging level for the file. By default, the same as `level` parameter\ncolor       *bool*  True    True  - Prints a colored message to the terminal (default), False - Prints a monochrome message to the terminal\ndebug       *bool*  False   True  - Sets logging level to DEBUG (rewrites `level` parameter), works the same as level=\"DEBUG\". False - Gets logging level from `level` parameter (default)\n=========== ======= ======= ============================================================================================\n\n\ndebug()\n-------\n**debug(args, kwargs)** - Log a message with severity \"DEBUG\"\n\n\ndiag_info()\n-----------\n**diag_info(msg, args, kwargs)** - Log diagnostic message with severity \"INFO\"\n\n\ndiag_warning()\n--------------\n**diag_warning(msg, args, kwargs)** - Log diagnostic message with severity \"WARNING\"\n\n\ninfo()\n------\n**info(args, kwargs)** - Log a message with severity \"INFO\"\n\n\nwarning()\n---------\n**warning(args, kwargs)** - Log a message with severity \"WARNING\"\n\n\nerror()\n-------\n**error(args, kwargs)** - Log a message with severity \"ERROR\"\n\n\ncritical()\n----------\n**warning(args, kwargs)** - Log a message with severity \"CRITICAL\"\n\n\n**Example**\n\n.. code:: python\n\n    import logger_color\n\n    logger_color.start_logging(filename=\"/var/log/test.log\", level=\"debug\", level_file=\"error\")\n    logger_color.debug(\"debug\")\n    logger_color.info(\"info\")\n    logger_color.warning(\"warning\")\n    logger_color.error(\"error\")\n    logger_color.critical(\"critical\")\n    logger_color.diag_info(\"diag_info\")\n    logger_color.diag_warning(\"diag_warning\")\n    # 2024-10-19 11:03:25.691 DEBUG    functions.debug: debug\n    # 2024-10-19 11:03:25.691 INFO     functions.info: info\n    # 2024-10-19 11:03:25.691 WARNING  functions.warning: warning\n    # 2024-10-19 11:03:25.691 ERROR    functions.error: error\n    # 2024-10-19 11:03:25.691 CRITICAL functions.critical: critical\n    # 2024-10-19 11:03:25.691 DIAG_I   examples_messages.<module>: diag_info\n    # 2024-10-19 11:03:25.691 DIAG_W   examples_messages.<module>: diag_warning\n\n    # cat /var/log/test.log\n    # 2024-10-19 11:03:25 ERROR    error\n    # 2024-10-19 11:03:25 CRITICAL critical\n\n",
    "bugtrack_url": null,
    "license": "Apache-2.0",
    "summary": "Color the log message headers and add more logging levels for diagnostics.",
    "version": "0.1.0",
    "project_urls": {
        "Bug Tracker": "https://github.com/vladimirs-git/logger-color/issues",
        "Download URL": "https://github.com/vladimirs-git/logger-color/archive/refs/tags/0.1.0.tar.gz",
        "Homepage": "https://github.com/vladimirs-git/logger-color",
        "Repository": "https://github.com/vladimirs-git/logger-color"
    },
    "split_keywords": [
        "logging",
        " logger",
        " color"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "eb15d6a21d7c22705eececd2505351a6fafeb60d5352c02bd66e4726ecbfa0d3",
                "md5": "ddede8b7a70242fdb05aea1784b9c950",
                "sha256": "1232dbaa5404be9abdb8a99bcf979d11618b65dd74d89c1365e02cb9ea2a891a"
            },
            "downloads": -1,
            "filename": "logger_color-0.1.0.tar.gz",
            "has_sig": false,
            "md5_digest": "ddede8b7a70242fdb05aea1784b9c950",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": "<4.0,>=3.8",
            "size": 9546,
            "upload_time": "2024-10-19T08:21:27",
            "upload_time_iso_8601": "2024-10-19T08:21:27.092265Z",
            "url": "https://files.pythonhosted.org/packages/eb/15/d6a21d7c22705eececd2505351a6fafeb60d5352c02bd66e4726ecbfa0d3/logger_color-0.1.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-10-19 08:21:27",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "vladimirs-git",
    "github_project": "logger-color",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "requirements": [],
    "lcname": "logger-color"
}
        
Elapsed time: 0.35671s