simplelogging


Namesimplelogging JSON
Version 0.12.0 PyPI version JSON
download
home_pagehttps://github.com/vpoulailleau/simplelogging
SummaryLogging made simple, no excuse for any debug print call.
upload_time2024-07-02 09:29:03
maintainerNone
docs_urlNone
authorVincent Poulailleau
requires_python<4.0,>=3.8
licenseBSD-3-Clause
keywords logging simplelogging
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI
coveralls test coverage No coveralls.
            # Simple Logging

[![PyPI](https://img.shields.io/pypi/v/simplelogging.svg)](https://pypi.python.org/pypi/simplelogging)
[![PyPI](https://img.shields.io/pypi/l/simplelogging.svg)](https://github.com/vpoulailleau/simplelogging/blob/master/LICENSE)
[![Travis](https://img.shields.io/travis/vpoulailleau/simplelogging.svg)](https://travis-ci.org/vpoulailleau/simplelogging)
[![ReadTheDocs](https://readthedocs.org/projects/simplelogging/badge/?version=latest)](https://simplelogging.readthedocs.io/en/latest/?badge=latest)
[![Code style: Black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/ambv/black)
[![Downloads](https://pepy.tech/badge/simplelogging)](https://pepy.tech/project/simplelogging)
[![Test Coverage](https://api.codeclimate.com/v1/badges/4ad8f1bef2c011e8a5ac/test_coverage)](https://codeclimate.com/github/vpoulailleau/simplelogging/test_coverage)
[![Maintainability](https://api.codeclimate.com/v1/badges/4ad8f1bef2c011e8a5ac/maintainability)](https://codeclimate.com/github/vpoulailleau/simplelogging/maintainability)

Logging made simple, no excuse for any debug print call.

* Free software: BSD 3-Clause license
* Documentation: https://simplelogging.readthedocs.io.


## Features

* Logging management (debug, information or error messages)
* Simple logging setup
* Based on Python `logging` module of the standard library
* Based on [colorlog](https://github.com/borntyping/python-colorlog) for colored log on console

For advanced users:

* The provided logger is one of those from `logging`, this means it can be configured so that log messages are sent by email, HTTP, or any of the options available in https://docs.python.org/3/library/logging.handlers.html.
* The StreamHandler and the associated Formatter are those provided by `colorlog`.

## Example

### Basic usage

```python
import simplelogging

# log = simplelogging.get_logger(console_level=simplelogging.DEBUG)
# log = simplelogging.get_logger(file_name="log.txt")
log = simplelogging.get_logger()

a_string_variable = "hello"
an_integer_variable = 42
a_floating_point_variable = 3.14

log.debug("some debug")
log.info("some info")
log.info(
    "some variables: %s, %d, %f",
    a_string_variable,
    an_integer_variable,
    a_floating_point_variable,
)
log.warning("some warning")
log.error("some error")
log.critical("some critical error")

try:
    x = 1 / 0
except ZeroDivisionError as error:
    log.exception(error)
```

![quickstart result](quickstart.png)

Keep in mind that you shouldn't do string formatting yourself. Delegate formatting to `simplelogging` (i.e. `logging` in this case), the formatting will be done only if necessary, that is if the message is going to be displayed. See above examples of how to display variables.

### Usage with modules

#### example_module.py

```python
import simplelogging

log = simplelogging.get_logger()


def log_some_messages():
    log.debug("## some debug ##")
    log.info("## some info ##")
    log.warning("## some warning ##")
    log.error("## some error ##")
```

#### main.py

```python
import example_module
import simplelogging

# log = simplelogging.get_logger(console_level=simplelogging.DEBUG)
# log = simplelogging.get_logger(file_name="log.txt")
log = simplelogging.get_logger()

a_variable = "a nice variable"
another_variable = 42

log.error("---- normal logging ----")
log.debug("a debug message")
log.info("an info")
log.warning("a warning")
log.error("%s and %d", a_variable, another_variable)

log.error("---- example_module writes to the log ----")
example_module.log_some_messages()

log.error("---- reduced logging (bye debug and info messages) ----")
log.reduced_logging()
log.debug("a debug message")
log.info("an info")
log.warning("a warning")
log.error("an error")

log.error("---- full logging (welcome back debug and info messages) ----")
log.full_logging()
log.debug("a debug message")
log.info("an info")
log.warning("a warning")
log.error("an error")
```

#### Result in the console


![quickstart with modules result](with_modules.png)

More examples are provided in the documentation: https://simplelogging.readthedocs.io.

## TODO

* add tests
* add type annotations
* add docstring
* commit hooks
* describe pros/cons and alternatives
* release 1.0!

## Credits

This package is an extension of the [logging](https://docs.python.org/3/howto/logging-cookbook.html) package in the Python standard library. Coloring of the console relies on [colorlog](https://github.com/borntyping/python-colorlog).

## Changelog

### 0.12.0 (2024-07-02)

* Drop Python 3.7 support
* Switch to Poetry core as a build engine

### 0.11.0 (2020-08-31)

* Use poetry

### 0.10.0 (2019-09-16)

* setup.py: require pytest-runner only when necessary
* Remove Python 3.4 support

### 0.9.0 (2018-12-14)

* Improve documentation
* Add tests
* Change API for easy logging level change

### 0.8.0 (2018-12-09)

* Improve documentation
* Change default format: enlarge level size for critical errors

### 0.7.0 (2018-12-08)

* Fix logging to file

### 0.6.0 (2018-12-07)

* Colored output on console
* Improved documentation

### 0.5.0 (2018-12-02)

* Fix README rendering in PyPI

### 0.4.0 (2018-12-02)

* Fix bump config

### 0.3.0 (2018-12-02)

* First release on PyPI.


            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/vpoulailleau/simplelogging",
    "name": "simplelogging",
    "maintainer": null,
    "docs_url": null,
    "requires_python": "<4.0,>=3.8",
    "maintainer_email": null,
    "keywords": "logging, simplelogging",
    "author": "Vincent Poulailleau",
    "author_email": "vpoulailleau@gmail.com",
    "download_url": "https://files.pythonhosted.org/packages/30/71/d6b6513598e6a4300f6142a839d1b0e10a25a4707f1b586d9a6331be91bb/simplelogging-0.12.0.tar.gz",
    "platform": null,
    "description": "# Simple Logging\n\n[![PyPI](https://img.shields.io/pypi/v/simplelogging.svg)](https://pypi.python.org/pypi/simplelogging)\n[![PyPI](https://img.shields.io/pypi/l/simplelogging.svg)](https://github.com/vpoulailleau/simplelogging/blob/master/LICENSE)\n[![Travis](https://img.shields.io/travis/vpoulailleau/simplelogging.svg)](https://travis-ci.org/vpoulailleau/simplelogging)\n[![ReadTheDocs](https://readthedocs.org/projects/simplelogging/badge/?version=latest)](https://simplelogging.readthedocs.io/en/latest/?badge=latest)\n[![Code style: Black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/ambv/black)\n[![Downloads](https://pepy.tech/badge/simplelogging)](https://pepy.tech/project/simplelogging)\n[![Test Coverage](https://api.codeclimate.com/v1/badges/4ad8f1bef2c011e8a5ac/test_coverage)](https://codeclimate.com/github/vpoulailleau/simplelogging/test_coverage)\n[![Maintainability](https://api.codeclimate.com/v1/badges/4ad8f1bef2c011e8a5ac/maintainability)](https://codeclimate.com/github/vpoulailleau/simplelogging/maintainability)\n\nLogging made simple, no excuse for any debug print call.\n\n* Free software: BSD 3-Clause license\n* Documentation: https://simplelogging.readthedocs.io.\n\n\n## Features\n\n* Logging management (debug, information or error messages)\n* Simple logging setup\n* Based on Python `logging` module of the standard library\n* Based on [colorlog](https://github.com/borntyping/python-colorlog) for colored log on console\n\nFor advanced users:\n\n* The provided logger is one of those from `logging`, this means it can be configured so that log messages are sent by email, HTTP, or any of the options available in https://docs.python.org/3/library/logging.handlers.html.\n* The StreamHandler and the associated Formatter are those provided by `colorlog`.\n\n## Example\n\n### Basic usage\n\n```python\nimport simplelogging\n\n# log = simplelogging.get_logger(console_level=simplelogging.DEBUG)\n# log = simplelogging.get_logger(file_name=\"log.txt\")\nlog = simplelogging.get_logger()\n\na_string_variable = \"hello\"\nan_integer_variable = 42\na_floating_point_variable = 3.14\n\nlog.debug(\"some debug\")\nlog.info(\"some info\")\nlog.info(\n    \"some variables: %s, %d, %f\",\n    a_string_variable,\n    an_integer_variable,\n    a_floating_point_variable,\n)\nlog.warning(\"some warning\")\nlog.error(\"some error\")\nlog.critical(\"some critical error\")\n\ntry:\n    x = 1 / 0\nexcept ZeroDivisionError as error:\n    log.exception(error)\n```\n\n![quickstart result](quickstart.png)\n\nKeep in mind that you shouldn't do string formatting yourself. Delegate formatting to `simplelogging` (i.e. `logging` in this case), the formatting will be done only if necessary, that is if the message is going to be displayed. See above examples of how to display variables.\n\n### Usage with modules\n\n#### example_module.py\n\n```python\nimport simplelogging\n\nlog = simplelogging.get_logger()\n\n\ndef log_some_messages():\n    log.debug(\"## some debug ##\")\n    log.info(\"## some info ##\")\n    log.warning(\"## some warning ##\")\n    log.error(\"## some error ##\")\n```\n\n#### main.py\n\n```python\nimport example_module\nimport simplelogging\n\n# log = simplelogging.get_logger(console_level=simplelogging.DEBUG)\n# log = simplelogging.get_logger(file_name=\"log.txt\")\nlog = simplelogging.get_logger()\n\na_variable = \"a nice variable\"\nanother_variable = 42\n\nlog.error(\"---- normal logging ----\")\nlog.debug(\"a debug message\")\nlog.info(\"an info\")\nlog.warning(\"a warning\")\nlog.error(\"%s and %d\", a_variable, another_variable)\n\nlog.error(\"---- example_module writes to the log ----\")\nexample_module.log_some_messages()\n\nlog.error(\"---- reduced logging (bye debug and info messages) ----\")\nlog.reduced_logging()\nlog.debug(\"a debug message\")\nlog.info(\"an info\")\nlog.warning(\"a warning\")\nlog.error(\"an error\")\n\nlog.error(\"---- full logging (welcome back debug and info messages) ----\")\nlog.full_logging()\nlog.debug(\"a debug message\")\nlog.info(\"an info\")\nlog.warning(\"a warning\")\nlog.error(\"an error\")\n```\n\n#### Result in the console\n\n\n![quickstart with modules result](with_modules.png)\n\nMore examples are provided in the documentation: https://simplelogging.readthedocs.io.\n\n## TODO\n\n* add tests\n* add type annotations\n* add docstring\n* commit hooks\n* describe pros/cons and alternatives\n* release 1.0!\n\n## Credits\n\nThis package is an extension of the [logging](https://docs.python.org/3/howto/logging-cookbook.html) package in the Python standard library. Coloring of the console relies on [colorlog](https://github.com/borntyping/python-colorlog).\n\n## Changelog\n\n### 0.12.0 (2024-07-02)\n\n* Drop Python 3.7 support\n* Switch to Poetry core as a build engine\n\n### 0.11.0 (2020-08-31)\n\n* Use poetry\n\n### 0.10.0 (2019-09-16)\n\n* setup.py: require pytest-runner only when necessary\n* Remove Python 3.4 support\n\n### 0.9.0 (2018-12-14)\n\n* Improve documentation\n* Add tests\n* Change API for easy logging level change\n\n### 0.8.0 (2018-12-09)\n\n* Improve documentation\n* Change default format: enlarge level size for critical errors\n\n### 0.7.0 (2018-12-08)\n\n* Fix logging to file\n\n### 0.6.0 (2018-12-07)\n\n* Colored output on console\n* Improved documentation\n\n### 0.5.0 (2018-12-02)\n\n* Fix README rendering in PyPI\n\n### 0.4.0 (2018-12-02)\n\n* Fix bump config\n\n### 0.3.0 (2018-12-02)\n\n* First release on PyPI.\n\n",
    "bugtrack_url": null,
    "license": "BSD-3-Clause",
    "summary": "Logging made simple, no excuse for any debug print call.",
    "version": "0.12.0",
    "project_urls": {
        "Documentation": "https://simplelogging.readthedocs.io/en/latest/",
        "Homepage": "https://github.com/vpoulailleau/simplelogging",
        "Repository": "https://github.com/vpoulailleau/simplelogging"
    },
    "split_keywords": [
        "logging",
        " simplelogging"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "0ae8e1c4a2bc2a3ee645fb82e4420c46f90f5780ddbe12a61df3247cb4e9c063",
                "md5": "2108b9604548c80ca87558c900ddeb04",
                "sha256": "bca5628e427d32d3e6ef48e1ef1ff85b6af6ea0710037cc5dd5a9c9bf70df4a0"
            },
            "downloads": -1,
            "filename": "simplelogging-0.12.0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "2108b9604548c80ca87558c900ddeb04",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": "<4.0,>=3.8",
            "size": 5289,
            "upload_time": "2024-07-02T09:29:00",
            "upload_time_iso_8601": "2024-07-02T09:29:00.933163Z",
            "url": "https://files.pythonhosted.org/packages/0a/e8/e1c4a2bc2a3ee645fb82e4420c46f90f5780ddbe12a61df3247cb4e9c063/simplelogging-0.12.0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "3071d6b6513598e6a4300f6142a839d1b0e10a25a4707f1b586d9a6331be91bb",
                "md5": "993862aca6fe6d0962effe07a335b554",
                "sha256": "a9695b05090951c029733606f14e24a783c7a100bbe96f8f16a5f2c4c9b08102"
            },
            "downloads": -1,
            "filename": "simplelogging-0.12.0.tar.gz",
            "has_sig": false,
            "md5_digest": "993862aca6fe6d0962effe07a335b554",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": "<4.0,>=3.8",
            "size": 4898,
            "upload_time": "2024-07-02T09:29:03",
            "upload_time_iso_8601": "2024-07-02T09:29:03.734743Z",
            "url": "https://files.pythonhosted.org/packages/30/71/d6b6513598e6a4300f6142a839d1b0e10a25a4707f1b586d9a6331be91bb/simplelogging-0.12.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-07-02 09:29:03",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "vpoulailleau",
    "github_project": "simplelogging",
    "travis_ci": true,
    "coveralls": false,
    "github_actions": false,
    "lcname": "simplelogging"
}
        
Elapsed time: 0.38222s