This is a logging framework. It is based on jk_logging but can be used with Asyncio.
Project description
jk_asyncio_logging
Introduction
This python module ...
Information about this module can be found here:
Why this module?
With jk_logging
there is a logging module available that allows constructing loggers from a JSON based description, offers buffers for log messages and supports hierarchical logging. Unfortunately this particular module is synchroneous and therefore can not be used in Asyncio
directly. This implementation therefore wraps jk_logging
and provides an API usable in Asyncio
.
Limitations of this module
This module provides classes wrapping (almost all) classes from jk_logging
. It provides almost all functionality despite one: Descending hierarchically is not supported. (This might change one day, but not in the near future.)
How to install module
This module can be installed easily using pip
.
Use this command for a system wide installation of this module:
$ sudo pip install jk-asyncio-logging
Use this command for user specific installation of this module:
$ pip install --user jk-asyncio-logging
The PiPy module is always kept in sync with the Github repository so using PyPi is equivalent to a manual installation using the code provided on Github.
How to use this module
Import this module
Please include this module into your application using the following code:
import jk_asyncio_logging
Construct a logger
Example:
log = jk_asyncio_logging.AsyncioConsoleLogger.create(logMsgFormatter=jk_asyncio_logging.COLOR_LOG_MESSAGE_FORMATTER)
Here we construct a console logger (which is an object that writes log messages to STDOUT.) It is configured for using colors for all output here.
Use the logger
You can create text based log messages and write them to the logger. Example:
await log.debug("This is a test for DEBUG.")
await log.notice("This is a test for NOTICE.")
await log.info("This is a test for INFO.")
await log.warning("This is a test for WARNING.")
await log.error("This is a test for ERROR.")
Exceptions can be logged as well. Example:
try:
await log.notice("Let's try a calculation that will fail ...")
a = 0
b = 5 / a
except Exception as ee:
await log.error(ee)
What kind of log objects are available?
You can make use of the following log objects:
AsyncioBufferLogger
- implements a buffer for log messages, which later on can be forwareded to another loggerAsyncioConsoleLogger
- implements writing to STDOUTAsyncioFileLogger
- implements writing to a fileAsyncioFilterLogger
- implements filtering of log messages according to log levelAsyncioMulticastLogger
- implements forwarding log messages to multiple loggersAsyncioNamedMulticastLogger
- implements forwarding log messages to multiple loggersAsyncioNullLogger
- discards all log messagesAsyncioStringListLogger
- implements a buffer for log messages, where all log messages are stored a plain text strings
Further Reading
See the test
directory for detailed examples of all loggers.
Contact Information
This is Open Source code. That not only gives you the possibility of freely using this code it also allows you to contribute. Feel free to contact the author(s) of this software listed below, either for comments, collaboration requests, suggestions for improvement or reporting bugs:
- Jürgen Knauth: jknauth@uni-goettingen.de, pubsrc@binary-overflow.de
License
This software is provided under the following license:
- Apache Software License 2.0
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
Hashes for jk_asyncio_logging-0.2019.10.19.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 40654a51c93affd14474f91355cbc282ef855054965347c01351b367b2cf2815 |
|
MD5 | d36585f019f326e70dbee4f9e7318be3 |
|
BLAKE2b-256 | aaa7602a366e4bd94c0fe32cbea5e49421e890e0221d1902734a49aa4b10c259 |