skullernet / q2pro

Enhanced Quake 2 client and server
GNU General Public License v2.0
243 stars 82 forks source link

systemd log to journal #168

Open fishxz opened 5 years ago

fishxz commented 5 years ago

hey, it seems there is a problem with logging to the journal.

i only get an ouput there, when i set "sys_console 1" and only the start process of q2pro.

Oct 11 16:55:05 alarmpi q2proded[22298]: 0 entities inhibited
Oct 11 16:55:05 alarmpi q2proded[22298]: 0 teams with 0 entities
Oct 11 16:55:05 alarmpi q2proded[22298]: [ SERVERTIME (port 28910) : Thu Oct 11 16:55:05 2018 ]
Oct 11 16:55:05 alarmpi q2proded[22298]: droptofloor: key_data_cd startsolid at (3264 2960 -2464)
Oct 11 16:55:05 alarmpi q2proded[22298]: droptofloor: item_adrenaline startsolid at (3280 2944 -2464)
Oct 11 16:55:05 alarmpi q2proded[22298]: -------------------------------------
Oct 11 16:55:05 alarmpi q2proded[22298]: ====== Q2PRO initialized ======
Oct 11 16:55:05 alarmpi q2proded[22298]: q2proded r1728~0604b7f, Oct 10 2018
Oct 11 16:55:05 alarmpi q2proded[22298]: https://github.com/skullernet/q2pro

after this no new messages will appear!

also i tried every possible "StandardOutput=" in my service file, without luck..

sthalik commented 5 years ago

stdin can't be null according to current logic. Use something that blocks forever and doesn't output anything. According to the systemd docs there's no particular way to do that. But that shell invocation seems to work even if its own stdin is duplicated from a /dev/null descriptor:

/bin/sh -c 'while sleep 3600; do :; done | ./q2proded +set sys_console 1 +map q2dm1'

It's probably better if set sys_console 2 ignored null input but that's a workaround that works right now.

fishxz commented 5 years ago

so after q2proded started, the output goes to null? is this intended and why is it like that?

sthalik commented 5 years ago

The input comes from /dev/null due to systemd and that's what's tripping up the console logic. Actually I have some time to fix the tty code since I've already worked on it.

sthalik commented 5 years ago

The code's intention seems to be to avoid polluting .xsession-errors with output once xterm detaches. But this seems consistent with this intention:

./q2proded +set sys_console 1 +map q2dm1

(patch moved to pull requests)

fishxz commented 5 years ago

it would be great if logfile_prefix would work in console aswell, otherwise using it is not a good replacement for the old way to log.

skullernet commented 5 years ago

External logger usually adds its own timestamps to messages. Isn't that enough?

fishxz commented 5 years ago

i have set logfile_prefix "@ [%Y-%m-%d %H:%M] ". the @ makes it easy to identify the content of the line and let me easy grep for textchat only.

sthalik commented 5 years ago

@fishxz I don't recommend the overhead of systemd's journal (vs appending to a flat file) for really no benefit. You can "rotate" a flat-file log by truncating the file in-place.