https://github.com/itsayellow/logrolling
An encapsulation of python logging to make using it easier and more pythonic.
https://github.com/itsayellow/logrolling
logging python
Last synced: 11 months ago
JSON representation
An encapsulation of python logging to make using it easier and more pythonic.
- Host: GitHub
- URL: https://github.com/itsayellow/logrolling
- Owner: itsayellow
- License: mit
- Created: 2019-06-27T21:38:17.000Z (about 7 years ago)
- Default Branch: master
- Last Pushed: 2020-02-26T07:06:31.000Z (over 6 years ago)
- Last Synced: 2025-06-20T07:43:06.012Z (about 1 year ago)
- Topics: logging, python
- Language: Python
- Homepage:
- Size: 8.79 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.txt
Awesome Lists containing this project
README
# logrolling
Like log-rolling in real life, logrolling takes an awkward activity,
(using logging), and attempts to make it seem effortless.
An encapsulation of python logging to make using it easier and more
pythonic.
## Use
You only need to use logrolling in the top module.
```
logger = logrolling.LogWrapper(
__name__,
[
"imported_module1",
"imported_module2",
"imported_module3",
],
use_console=True,
)
logger.add_filehandler("log.txt")
logger.debug("Starting logging")
```
Then, in the imported modules, you can either use logging or logroller.
`logging` example. The following would be at the top of `imported_module1`:
```
import logging
logger = logging.getLogger(__name__)
logger.addHandler(logging.NullHandler())
```
`logrolloing` example. The following would be at the top of `imported_module1`:
```
# logging for library defaults to NullHandler unless enabled by importing file
# use_console=False because importing file is already enabling it (don't dup)
logger = logrolling.LogWrapper(__name__, use_console=False)
logger.add_nullhandler()
```