Bin/bash logs screw up after running django query create - ÄDEBUGÅ instead [DEBUG]

When running this django command:

MyObjectBase.objects.create(
   ...,
   report_pdf=open(f"{REPORT_PATH}/{file_name}.pdf", "rb").read(),
   ...
)

My log output in the bin/bash console of VS Code in WSL2 (Ubuntu-22.04) on Win11 gets screwed.

Instead before the command:

[2024-10-21 13:40:52 +0200] [923356] [DEBUG] this is a debug message

I am getting logs like:

Ä21/Oct/2024:11:47:18 +0000Å ÄDEBUGÅ

Backticks turn into 'é'.

It looks like that during the create-command the binaries of the file are printed to the log like (just thousands of chars longer than this sample)

ÖxecoÖxc6Öxd2ÖxffÖxd6ÖxffKÖx00xyÖxchÖxfaÖxe66Öx7fÖx98Ö

This does not happen for every report, using different base data does not cause this effect. Unfortunately it is impossible for me to detect differences. I can say that the base data only contains strings and doubles and so on but no nested blobs or strings like code, but special chars like # are possible.

I tried another terminal. tmux was available by default. It does not face this problems, logs stay fine. But not using (one of) the most default terminals is not a valid solution for me.

So I am looking after the cause. As workaround I am suppressing the logs of this particular command using contextmanager.

Back to Top