update sendxmpp-handler-for-python-logging

This commit is contained in:
Trent Palmer 2020-12-19 08:51:41 -08:00
parent c2460a13e7
commit b9b5fb4337
4 changed files with 29 additions and 14 deletions

View File

@ -8,9 +8,17 @@ authors: ["trent"]
date: 2020-12-19
## **SENDXMPPHandler for Python Logging**
<script src="https://gist.github.com/adc541a6245d55e39edd10dab1001a88.js?file= SENDXMPPHandler.md"></script>
## **app/sendxmpp_handler.py**
<script src="https://gist.github.com/adc541a6245d55e39edd10dab1001a88.js?file= sendxmpp_handler.py"></script>
## **app/\__init__.py**
You may be familiar with adding a logging handler to a flask application, with something like the following in
`__init__.py`.
<script src="https://gist.github.com/adc541a6245d55e39edd10dab1001a88.js?file=__init__.py"></script>
## **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>
## **Android Yaxim Screenshot**
And this is what a flask logging error looks like on Android, in Yaxim.
![Yaxim Android Screenshot](https://gist.github.com/TrentSPalmer/adc541a6245d55e39edd10dab1001a88/raw/36f35a2d6c2c1c01633441542ff5d6ccb714c007/YaximAndroidScreenshot.png)

View File

@ -271,15 +271,15 @@
</li>
<li class="md-nav__item">
<a href="#appsendxmpp_handlerpy" class="md-nav__link">
app/sendxmpp_handler.py
<a href="#app__init__py" class="md-nav__link">
app/__init__.py
</a>
</li>
<li class="md-nav__item">
<a href="#app__init__py" class="md-nav__link">
app/__init__.py
<a href="#appsendxmpp_handlerpy" class="md-nav__link">
app/sendxmpp_handler.py
</a>
</li>
@ -477,15 +477,15 @@
</li>
<li class="md-nav__item">
<a href="#appsendxmpp_handlerpy" class="md-nav__link">
app/sendxmpp_handler.py
<a href="#app__init__py" class="md-nav__link">
app/__init__.py
</a>
</li>
<li class="md-nav__item">
<a href="#app__init__py" class="md-nav__link">
app/__init__.py
<a href="#appsendxmpp_handlerpy" class="md-nav__link">
app/sendxmpp_handler.py
</a>
</li>
@ -515,12 +515,19 @@
<p>date: 2020-12-19</p>
<h2 id="sendxmpphandler-for-python-logging"><strong>SENDXMPPHandler for Python Logging</strong></h2>
<script src="https://gist.github.com/adc541a6245d55e39edd10dab1001a88.js?file= SENDXMPPHandler.md"></script>
<h2 id="appsendxmpp_handlerpy"><strong>app/sendxmpp_handler.py</strong></h2>
<script src="https://gist.github.com/adc541a6245d55e39edd10dab1001a88.js?file= sendxmpp_handler.py"></script>
<h2 id="app__init__py"><strong>app/__init__.py</strong></h2>
<p>You may be familiar with adding a logging handler to a flask application, with something like the following in
<code>__init__.py</code>.</p>
<script src="https://gist.github.com/adc541a6245d55e39edd10dab1001a88.js?file=__init__.py"></script>
<h2 id="appsendxmpp_handlerpy"><strong>app/sendxmpp_handler.py</strong></h2>
<p>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 <a href="https://github.com/python/cpython/blob/master/Lib/logging/handlers.py" target="_blank">handlers.py</a>.</p>
<p>Using the available handlers as an example, it did not require a lot of imagination to come up with
SENDXMPPHandler.</p>
<script src="https://gist.github.com/adc541a6245d55e39edd10dab1001a88.js?file= sendxmpp_handler.py"></script>
<h2 id="android-yaxim-screenshot"><strong>Android Yaxim Screenshot</strong></h2>
<p><img alt="Yaxim Android Screenshot" src="https://gist.github.com/TrentSPalmer/adc541a6245d55e39edd10dab1001a88/raw/36f35a2d6c2c1c01633441542ff5d6ccb714c007/YaximAndroidScreenshot.png" /></p>
<p>And this is what a flask logging error looks like on Android, in Yaxim.
<img alt="Yaxim Android Screenshot" src="https://gist.github.com/TrentSPalmer/adc541a6245d55e39edd10dab1001a88/raw/36f35a2d6c2c1c01633441542ff5d6ccb714c007/YaximAndroidScreenshot.png" /></p>

File diff suppressed because one or more lines are too long

Binary file not shown.