Usefull commands : python / python3 json.tools

Viewing the log statements in Logstash

Django logging configuration

Logging is done mainly by configuring the Docker hosting Django to ship via UDP (same machine) the log statements.

sudo docker run               \
   -d                         \
   --network djangoNetwork    \
   --log-driver gelf --log-opt gelf-address=udp://<ip>:port \
   --log-opt tag=ITNDjango    \
   --name ITNDjango           \
   itndjango

Viewing the logs is pretty awfull

tail -f   /var/log/logstash/tls-All-Series/ITNDjango-2021-03-21.log  
{"image_name":"itndjango","image_id":"sha256:f390481f05a37970d29e52bafea81bc7f634d69b7d0cff6adc6491493cfb1101","@version":"1","message":"def handler500(request)::invoked. Request = <WSGIRequest: GET '/en/Schedule/'>","host":"tls-All-Series","@timestamp":"2021-03-21T15:34:45.163Z","version":"1.1","level":3,"container_name":"ITNDjango","source_host":"172.42.0.1","tag":"ITNDjango","container_id":"45331982c3ac6ea18671b04ef45cdb223ed268c381c4bc1d9766e2deb2509125","command":"gunicorn -b 0.0.0.0:8000 wsgi:application","created":"2021-03-21T15:28:42.53984554Z"}
{"image_name":"itndjango","image_id":"sha256:f390481f05a37970d29e52bafea81bc7f634d69b7d0cff6adc6491493cfb1101","@version":"1","message":"\r// BODY : b''","host":"tls-All-Series","@timestamp":"2021-03-21T15:34:45.164Z","version":"1.1","level":3,"container_name":"ITNDjango","source_host":"172.42.0.1","tag":"ITNDjango","container_id":"45331982c3ac6ea18671b04ef45cdb223ed268c381c4bc1d9766e2deb2509125","command":"gunicorn -b 0.0.0.0:8000 wsgi:application","created":"2021-03-21T15:28:42.53984554Z"}
{"image_name":"itndjango","image_id":"sha256:f390481f05a37970d29e52bafea81bc7f634d69b7d0cff6adc6491493cfb1101","@version":"1","message":"\r// Encoding : GET","host":"tls-All-Series","@timestamp":"2021-03-21T15:34:45.175Z","version":"1.1","level":3,"container_name":"ITNDjango","source_host":"172.42.0.1","tag":"ITNDjango","container_id":"45331982c3ac6ea18671b04ef45cdb223ed268c381c4bc1d9766e2deb2509125","command":"gunicorn -b 0.0.0.0:8000 wsgi:application","created":"2021-03-21T15:28:42.53984554Z"}
{"image_name":"itndjango","image_id":"sha256:f390481f05a37970d29e52bafea81bc7f634d69b7d0cff6adc6491493cfb1101","@version":"1","message":"\r ","host":"tls-All-Series","@timestamp":"2021-03-21T15:34:45.176Z","version":"1.1","level":3,"container_name":"ITNDjango","source_host":"172.42.0.1","tag":"ITNDjango","container_id":"45331982c3ac6ea18671b04ef45cdb223ed268c381c4bc1d9766e2deb2509125","command":"gunicorn -b 0.0.0.0:8000 wsgi:application","created":"2021-03-21T15:28:42.53984554Z"}
{"image_name":"itndjango","image_id":"sha256:f390481f05a37970d29e52bafea81bc7f634d69b7d0cff6adc6491493cfb1101","@version":"1","message":"ERROR : ************************************************* ","host":"tls-All-Series","@timestamp":"2021-03-21T15:34:45.164Z","version":"1.1","level":3,"container_name":"ITNDjango","source_host":"172.42.0.1","tag":"ITNDjango","container_id":"45331982c3ac6ea18671b04ef45cdb223ed268c381c4bc1d9766e2deb2509125","command":"gunicorn -b 0.0.0.0:8000 …
more ...

BASH in colors

Problem

When scripting some tasks it is always better to use clear marking of what is OK (in green) and what is not OK (in Red). Now this was easy with simple colors but we sometimes require more than 2 colours.

Escape characters

As often, I saw a good trick and Copy-Pasted it without asking myself anything further.

Today every shell scripts (99,9% of the time bash) are like what follows.

#!/bin/bash

# Author     : "Thomas Lionel SMETS"
# Copyrights : "All rights reserved 2006-2021, A3-SYSTEM srl-bv"
# #####################################################################

#    .---------- constant part!
#    vvvv vvvv-- the …
more ...

Forking on GitHub

Problem

I create my own bb code translation to allow external parties to update my site and limit their possibility of wrong doing. So basically code change a tag like [b]bold[/b] to <b>bold</b>... to render a text in bold.

This ensure that I can guarantee that nobody can create titles with his/her own formatting making the site more consistent on a UI.

After a while, I realize tha the BBcode project was doing in several places a better job.

What I did ...

Cloned the Git up repo

  • Cloned the repo
  • Created a virtualenv environment
  • Created …
more ...