News:

Do you need help?
Simutrans Wiki Manual can help you to play and extend Simutrans. In 9 languages.

Logging

Started by jamespetts, May 11, 2014, 01:17:11 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

jamespetts

Is there any way of which anyone is aware to (1) customise the directory into which the Linux server build of Simutrans records its logs; and (2) require that the existing log file, if any, at that location is appended rather than overwritten? I am having trouble tracking down crashes on my server because the restart script causes the log file to be overwritten.
Download Simutrans-Extended.

Want to help with development? See here for things to do for coding, and here for information on how to make graphics/objects.

Follow Simutrans-Extended on Facebook.

Ters

If you have a script that restarts the server, then I would recommend changing that script so that it renames the old log file first. That's a better solution than appending, as you can then open the old log in peace (it isn't written to it anymore) and find the last things that happened at the bottom (no need to search for it). As a bonus, you can also see how often and when it restarted.

jamespetts

Yes, I see - and presumably, the script would also need to rename the old log that it previously re-named, and so on ad infinitum...?
Download Simutrans-Extended.

Want to help with development? See here for things to do for coding, and here for information on how to make graphics/objects.

Follow Simutrans-Extended on Facebook.

Ters

No, you give each log file a unique name. The easiest, and perhaps most popular way of doing that, is by including the current date and time in the file name.

jamespetts

Ahh, yes, I see. I have had a go at modifying the script to do this, although my shell scripting knowledge is limited, so I am not sure whether it will work.
Download Simutrans-Extended.

Want to help with development? See here for things to do for coding, and here for information on how to make graphics/objects.

Follow Simutrans-Extended on Facebook.

Ters

Something like mv simu.log simu.log.`date +%FT%T` perhaps. %T means the file name will include colons. If this is a problem, a different format argument must be passed to date. See date --help for that.

jamespetts

#6
What I have done is this:


now=$(date +"%d_m%_%Y")
/bin/sh -c "cp /usr/share/games/simutrans-experimental/simutrans/simu-server13353.log /var/log/old-log_$now.log"


Does this look workable to you?

Edit: Sadly, this does not seem to work, and it is not clear why.
Download Simutrans-Extended.

Want to help with development? See here for things to do for coding, and here for information on how to make graphics/objects.

Follow Simutrans-Extended on Facebook.

An_dz

It is the m% which should be %m. now was receiving m%y. I would include _%T at now to include the time.

jamespetts

Quote from: An_dz on May 12, 2014, 03:43:27 AM
It is the m% which should be %m. now was receiving m%y. I would include _%T at now to include the time.

Ahh, splendid, thank you - modified accordingly.
Download Simutrans-Extended.

Want to help with development? See here for things to do for coding, and here for information on how to make graphics/objects.

Follow Simutrans-Extended on Facebook.

Ashley

Best to build Simutrans with syslog support, and then manage your logs through that (most Linux systems come with logrotate or a derivative).
Use Firefox? Interested in IPv6? Try SixOrNot the IPv6 status indicator for Firefox.
Why not try playing Simutrans online? See the Game Servers board for details.

jamespetts

Hmm - how would one build Simutrans with syslog support...?
Download Simutrans-Extended.

Want to help with development? See here for things to do for coding, and here for information on how to make graphics/objects.

Follow Simutrans-Extended on Facebook.

Ters

It's documented it config.template, which is the place for customizing the build (except MSVC builds, and possibly native MacOS).

Ashley

Yeah, it's in config.template:

FLAGS = -DSYSLOG
Use Firefox? Interested in IPv6? Try SixOrNot the IPv6 status indicator for Firefox.
Why not try playing Simutrans online? See the Game Servers board for details.

Ters

...although I did look in config.default first, and could not find it. Which makes perfect sense, since I only sync config.default from config.template on rare occasions. It's one of the tripwires when having templates in VCS that needs to be copied and configured for each workspace: the file you normally use is almost never up-to-date. But configuring the file that lies in VCS is more dangerous, if you have commit rights, just for everyone else but you.

jamespetts

Thank you very much for this: that is most helpful. I have now amended the config.default on my server to include this, so it should be incorporated into the next build.
Download Simutrans-Extended.

Want to help with development? See here for things to do for coding, and here for information on how to make graphics/objects.

Follow Simutrans-Extended on Facebook.