2020-12-19 03:47:41 -08:00
|
|
|
---
|
|
|
|
title: "SENDXMPPHandler for Python Logging"
|
|
|
|
date: 2020-12-19
|
|
|
|
draft: false
|
|
|
|
tags: ["Python","Logging","Flask","XMPP","SENDXMPP","logging.Handler"]
|
|
|
|
authors: ["trent"]
|
|
|
|
---
|
|
|
|
date: 2020-12-19
|
|
|
|
## **SENDXMPPHandler for Python Logging**
|
|
|
|
<script src="https://gist.github.com/adc541a6245d55e39edd10dab1001a88.js?file= SENDXMPPHandler.md"></script>
|
|
|
|
## **app/\__init__.py**
|
2020-12-19 08:51:41 -08:00
|
|
|
You may be familiar with adding a logging handler to a flask application, with something like the following in
|
|
|
|
`__init__.py`.
|
2020-12-19 03:47:41 -08:00
|
|
|
<script src="https://gist.github.com/adc541a6245d55e39edd10dab1001a88.js?file=__init__.py"></script>
|
2020-12-19 08:51:41 -08:00
|
|
|
## **app/sendxmpp_handler.py**
|
|
|
|
python-logging doesn't have a handler for xmpp but the handlers that are available are easy enough to
|
|
|
|
understand if you read through them in [handlers.py](https://github.com/python/cpython/blob/master/Lib/logging/handlers.py){target=_blank}.
|
|
|
|
|
|
|
|
Using the available handlers as an example, it did not require a lot of imagination to come up with
|
|
|
|
SENDXMPPHandler.
|
|
|
|
<script src="https://gist.github.com/adc541a6245d55e39edd10dab1001a88.js?file= sendxmpp_handler.py"></script>
|
2020-12-19 03:47:41 -08:00
|
|
|
## **Android Yaxim Screenshot**
|
2020-12-19 08:51:41 -08:00
|
|
|
And this is what a flask logging error looks like on Android, in Yaxim.
|
2020-12-19 03:47:41 -08:00
|
|
|
![Yaxim Android Screenshot](https://gist.github.com/TrentSPalmer/adc541a6245d55e39edd10dab1001a88/raw/36f35a2d6c2c1c01633441542ff5d6ccb714c007/YaximAndroidScreenshot.png)
|