treewide: fix flushing of messages to logs in some cases
... by setting FILE* properties and replace the explicit flushes. Explicit flushing couldn't be well done e.g. for lua's error() function. In particular, we had problems with journald not getting logs timely.
- tested it fixes the issue on NixOS+systemd desktop.