Logging made simple, no excuse for any print call.
Project description
# Simple Logging
[![PyPI](https://img.shields.io/pypi/v/simplelogging.svg)](https://pypi-hypernode.com/pypi/simplelogging)
[![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)
Logging made simple, no excuse for any print call.
* Free software: BSD 3-Clause license
* Documentation: https://simplelogging.readthedocs.io.
## Features
* Simple logging setup
* Based on Python logging module
## Example
### 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 simplelogging
import example_module
# 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) ----")
simplelogging.reduced_logging(log)
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) ----")
simplelogging.full_logging(log)
log.debug("a debug message")
log.info("an info")
log.warning("a warning")
log.error("an error")
```
### Result in the console
```
2018-12-02 18:44:34,897 [ERROR ] main_simple.py( 11):<module> :: ---- normal logging ----
2018-12-02 18:44:34,897 [INFO ] main_simple.py( 13):<module> :: an info
2018-12-02 18:44:34,898 [WARNING] main_simple.py( 14):<module> :: a warning
2018-12-02 18:44:34,898 [ERROR ] main_simple.py( 15):<module> :: a nice variable and 42
2018-12-02 18:44:34,898 [ERROR ] main_simple.py( 17):<module> :: ---- example_module writes to the log ----
2018-12-02 18:44:34,899 [INFO ] example_module.py( 8):log_some_messages :: ## some info ##
2018-12-02 18:44:34,899 [WARNING] example_module.py( 9):log_some_messages :: ## some warning ##
2018-12-02 18:44:34,899 [ERROR ] example_module.py( 10):log_some_messages :: ## some error ##
2018-12-02 18:44:34,900 [ERROR ] main_simple.py( 20):<module> :: ---- reduced logging (bye debug and info messages) ----
2018-12-02 18:44:34,900 [WARNING] main_simple.py( 24):<module> :: a warning
2018-12-02 18:44:34,901 [ERROR ] main_simple.py( 25):<module> :: an error
2018-12-02 18:44:34,901 [ERROR ] main_simple.py( 27):<module> :: ---- full logging (welcome back debug and info messages) ----
2018-12-02 18:44:34,901 [INFO ] main_simple.py( 30):<module> :: an info
2018-12-02 18:44:34,902 [WARNING] main_simple.py( 31):<module> :: a warning
2018-12-02 18:44:34,902 [ERROR ] main_simple.py( 32):<module> :: an error
```
## Credits
This package is an extension of the logging package in the Python standard library.
This package was created with [Cookiecutter](https://github.com/audreyr/cookiecutter) and the [audreyr/cookiecutter-pypackage](https://github.com/audreyr/cookiecutter-pypackage) project template.
=======
History
=======
0.3.0 (2018-12-02)
------------------
* First release on PyPI.
0.4.0 (2018-12-02)
------------------
* Fix bump config
[![PyPI](https://img.shields.io/pypi/v/simplelogging.svg)](https://pypi-hypernode.com/pypi/simplelogging)
[![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)
Logging made simple, no excuse for any print call.
* Free software: BSD 3-Clause license
* Documentation: https://simplelogging.readthedocs.io.
## Features
* Simple logging setup
* Based on Python logging module
## Example
### 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 simplelogging
import example_module
# 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) ----")
simplelogging.reduced_logging(log)
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) ----")
simplelogging.full_logging(log)
log.debug("a debug message")
log.info("an info")
log.warning("a warning")
log.error("an error")
```
### Result in the console
```
2018-12-02 18:44:34,897 [ERROR ] main_simple.py( 11):<module> :: ---- normal logging ----
2018-12-02 18:44:34,897 [INFO ] main_simple.py( 13):<module> :: an info
2018-12-02 18:44:34,898 [WARNING] main_simple.py( 14):<module> :: a warning
2018-12-02 18:44:34,898 [ERROR ] main_simple.py( 15):<module> :: a nice variable and 42
2018-12-02 18:44:34,898 [ERROR ] main_simple.py( 17):<module> :: ---- example_module writes to the log ----
2018-12-02 18:44:34,899 [INFO ] example_module.py( 8):log_some_messages :: ## some info ##
2018-12-02 18:44:34,899 [WARNING] example_module.py( 9):log_some_messages :: ## some warning ##
2018-12-02 18:44:34,899 [ERROR ] example_module.py( 10):log_some_messages :: ## some error ##
2018-12-02 18:44:34,900 [ERROR ] main_simple.py( 20):<module> :: ---- reduced logging (bye debug and info messages) ----
2018-12-02 18:44:34,900 [WARNING] main_simple.py( 24):<module> :: a warning
2018-12-02 18:44:34,901 [ERROR ] main_simple.py( 25):<module> :: an error
2018-12-02 18:44:34,901 [ERROR ] main_simple.py( 27):<module> :: ---- full logging (welcome back debug and info messages) ----
2018-12-02 18:44:34,901 [INFO ] main_simple.py( 30):<module> :: an info
2018-12-02 18:44:34,902 [WARNING] main_simple.py( 31):<module> :: a warning
2018-12-02 18:44:34,902 [ERROR ] main_simple.py( 32):<module> :: an error
```
## Credits
This package is an extension of the logging package in the Python standard library.
This package was created with [Cookiecutter](https://github.com/audreyr/cookiecutter) and the [audreyr/cookiecutter-pypackage](https://github.com/audreyr/cookiecutter-pypackage) project template.
=======
History
=======
0.3.0 (2018-12-02)
------------------
* First release on PyPI.
0.4.0 (2018-12-02)
------------------
* Fix bump config
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
simplelogging-0.4.0.tar.gz
(9.4 kB
view details)
Built Distribution
File details
Details for the file simplelogging-0.4.0.tar.gz
.
File metadata
- Download URL: simplelogging-0.4.0.tar.gz
- Upload date:
- Size: 9.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.12.1 pkginfo/1.4.2 requests/2.20.1 setuptools/39.0.1 requests-toolbelt/0.8.0 tqdm/4.28.1 CPython/3.6.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 454e1d8f921e6f8b97dc3f2ab016afe7da8a3bd0b03f1b3c6730dcef23ee2aad |
|
MD5 | d424a804aad7f9efd1bb2c25d9752332 |
|
BLAKE2b-256 | c38aee4fe1b9c7abd848961e10a1ec44e7ce5acfdd51a57582cdfe3d37221ae5 |
File details
Details for the file simplelogging-0.4.0-py2.py3-none-any.whl
.
File metadata
- Download URL: simplelogging-0.4.0-py2.py3-none-any.whl
- Upload date:
- Size: 4.4 kB
- Tags: Python 2, Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.12.1 pkginfo/1.4.2 requests/2.20.1 setuptools/39.0.1 requests-toolbelt/0.8.0 tqdm/4.28.1 CPython/3.6.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | a007cd1b20d6239305099270c1aa264b8889bd53edf593cf3086083ad4f15f60 |
|
MD5 | d49a92d29c4411064595516e36385e64 |
|
BLAKE2b-256 | 22103b48c7e230f0f23bec127fbc966bd152083e42cada3b1b27a59ec6f04925 |