Last active
August 29, 2015 14:06
-
-
Save floreo/6380cfe7e0d2e509cd57 to your computer and use it in GitHub Desktop.
[teeworlds] convert hexa timestamp into datetime realtime log
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# may require gawk if you get the following error: function strftime never defined | |
# thanks to minus and guest__ for help on teeworlds IRC chan | |
teeworlds-server -f test.conf | gawk '{match($0, /\[([0-9a-f]+)\](.*)/, a); if(a[1]!="")$1="[" strftime("%F %T", strtonum("0x" a[1])) "]"; $1=$1a[2]; print }' | |
# simpler way (doesn't convert, simply dump the system's time, fflush is required to not have buffering issues) | |
teeworlds-server -f test.conf | gawk 'BEGIN { FS="]"; OFS=FS } /^\[.+\]/ { $1="["strftime("%F %T", systime()); print; fflush() }' &>>/var/log/teeworlds/test.log & | |
Changed output format and fixed the missing quotes:
[2014-09-06 17:27:19][datafile]: loading. filename='maps/dm1.map'
Depending on your needs, you can change the output format by defining the $1 part.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Convert this:
[540b27d7][datafile]: loading. filename='maps/dm1.map'
into that:
2014-09-06 17:27:19 - [datafile]: loading. filename=maps/dm1.map