Author Topic: Logging  (Read 2743 times)

0 Members and 1 Guest are viewing this topic.

Offline jamespetts

  • Simitrans-Extended project coordinator
  • Devotee
  • *
  • Posts: 14763
  • Total likes: 307
  • Helpful: 143
  • Cake baker
    • Bridgewater-Brunel
  • Languages: EN
Logging
« on: May 11, 2014, 01:17:11 PM »
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.

Offline Ters

  • Coder/patcher
  • Devotee
  • *
  • Posts: 4452
  • Total likes: 141
  • Helpful: 105
  • Languages: EN, NO
Re: Logging
« Reply #1 on: May 11, 2014, 02:16:19 PM »
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.

Offline jamespetts

  • Simitrans-Extended project coordinator
  • Devotee
  • *
  • Posts: 14763
  • Total likes: 307
  • Helpful: 143
  • Cake baker
    • Bridgewater-Brunel
  • Languages: EN
Re: Logging
« Reply #2 on: May 11, 2014, 02:31:58 PM »
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.

Offline Ters

  • Coder/patcher
  • Devotee
  • *
  • Posts: 4452
  • Total likes: 141
  • Helpful: 105
  • Languages: EN, NO
Re: Logging
« Reply #3 on: May 11, 2014, 03:26:25 PM »
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.

Offline jamespetts

  • Simitrans-Extended project coordinator
  • Devotee
  • *
  • Posts: 14763
  • Total likes: 307
  • Helpful: 143
  • Cake baker
    • Bridgewater-Brunel
  • Languages: EN
Re: Logging
« Reply #4 on: May 11, 2014, 06:54:36 PM »
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.

Offline Ters

  • Coder/patcher
  • Devotee
  • *
  • Posts: 4452
  • Total likes: 141
  • Helpful: 105
  • Languages: EN, NO
Re: Logging
« Reply #5 on: May 11, 2014, 07:10:48 PM »
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.

Offline jamespetts

  • Simitrans-Extended project coordinator
  • Devotee
  • *
  • Posts: 14763
  • Total likes: 307
  • Helpful: 143
  • Cake baker
    • Bridgewater-Brunel
  • Languages: EN
Re: Logging
« Reply #6 on: May 11, 2014, 08:00:48 PM »
What I have done is this:

Code: [Select]
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.
« Last Edit: May 11, 2014, 11:51:26 PM by jamespetts »
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.

Offline An_dz

  • Web Admin
  • Administrator
  • *
  • Posts: 2440
  • Total likes: 221
  • Helpful: 85
  • D'oh
    • by An_dz
  • Languages: PT, EN, (it, de)
Re: Logging
« Reply #7 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.

Offline jamespetts

  • Simitrans-Extended project coordinator
  • Devotee
  • *
  • Posts: 14763
  • Total likes: 307
  • Helpful: 143
  • Cake baker
    • Bridgewater-Brunel
  • Languages: EN
Re: Logging
« Reply #8 on: May 12, 2014, 09:35:20 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.

Offline Ashley

Re: Logging
« Reply #9 on: June 10, 2014, 09:40:01 AM »
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.

Offline jamespetts

  • Simitrans-Extended project coordinator
  • Devotee
  • *
  • Posts: 14763
  • Total likes: 307
  • Helpful: 143
  • Cake baker
    • Bridgewater-Brunel
  • Languages: EN
Re: Logging
« Reply #10 on: June 10, 2014, 09:51:36 AM »
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.

Offline Ters

  • Coder/patcher
  • Devotee
  • *
  • Posts: 4452
  • Total likes: 141
  • Helpful: 105
  • Languages: EN, NO
Re: Logging
« Reply #11 on: June 10, 2014, 02:18:47 PM »
It's documented it config.template, which is the place for customizing the build (except MSVC builds, and possibly native MacOS).

Offline Ashley

Re: Logging
« Reply #12 on: June 13, 2014, 11:30:14 AM »
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.

Offline Ters

  • Coder/patcher
  • Devotee
  • *
  • Posts: 4452
  • Total likes: 141
  • Helpful: 105
  • Languages: EN, NO
Re: Logging
« Reply #13 on: June 13, 2014, 02:27:27 PM »
...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.

Offline jamespetts

  • Simitrans-Extended project coordinator
  • Devotee
  • *
  • Posts: 14763
  • Total likes: 307
  • Helpful: 143
  • Cake baker
    • Bridgewater-Brunel
  • Languages: EN
Re: Logging
« Reply #14 on: June 13, 2014, 06:47:28 PM »
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.