Author Topic: Script log files location  (Read 815 times)

0 Members and 1 Guest are viewing this topic.

Offline DorkeyDear

  • Veteran
  • *****
  • Posts: 1507
  • I also go by Curt or menturi
Script log files location
« on: February 06, 2011, 11:08:30 am »
If a script writes its own logs, the location of the log files can vary depending on preference of the scripter. I was wondering, would it be more appropiate to put the logs of this script (lets say its titled SCRIPT_NAME) in (1) the ./logs/SCRIPT_NAME/ directory, or in (2) the ./scripts/SCRIPT_NAME/logs/ directory?

I personally find it more appropriate to have it in the logs directory (1) because logs are nice to have all in one spot for everything that pertains to the Soldat Dedicated Server, especially if multiple scripts communicate with one-another, its less of a pain to find. Also, with option (2), it would make hard-linking (or similar alternative) the script a bad idea since logs from multiple servers would be written to the same location in [possibly] the same file(s).

Although, in option (1), when a server owner installs the script, they must be aware they must create the SCRIPT_NAME directory in the logs directory, or the server may spill out errors (at least until functionality of creating directories is implemented without the use of shell_exec). This could be very annoying, especially when it is a popular script, and many people are wondering why installing the script makes the server spew out errors (which may result in a decrease in script usage). Option (2) avoids this since the logs directory is already existing when installing the script.

If you have other suggestions/options and comments, feel free to add.

I decided to put the pros and cons in lists:

For (1) / Against (2)
  • Single location for all logs pertaining to the single Soldat server
  • Script installer requires creation of script logs directory

For (2) / Against (1)
  • Hard-linking (or similar alternative) the script will cause for multiple servers' scripts to write logs in the same location

An aside question: How do you guys write logs? Do you put the date in the filename? Or is everything in a single file? Or do you have filenames associated to the types of logs?
« Last Edit: February 06, 2011, 11:22:19 am by DorkeyDear »

Offline dnmr

  • Camper
  • ***
  • Posts: 315
  • emotionally handicapped
Re: Script log files location
« Reply #1 on: February 06, 2011, 11:11:33 am »
./logs/SCRIPT_NAME/

Also, crapcore needs createdirectory(dirname: string) and directoryexists(dirname: string):boolean

Offline DorkeyDear

  • Veteran
  • *****
  • Posts: 1507
  • I also go by Curt or menturi
Re: Script log files location
« Reply #2 on: February 06, 2011, 11:18:04 am »
Also, crapcore needs createdirectory(dirname: string) and directoryexists(dirname: string):boolean
That can allow for the spewed errors to not happen, and then warn the server owner that logs are not being saved. I would be very happy if those existed :P

Offline dnmr

  • Camper
  • ***
  • Posts: 315
  • emotionally handicapped
Re: Script log files location
« Reply #3 on: February 06, 2011, 11:27:52 am »
"Script installer requires creation of script logs directory" is such a minor con really. Especially since adequate script releases have the folder structure included in the archive.

About log names - yup, have log type and date in the name so you can sort it (yyyy-mm-dd). That will cut the logs in small bits too so you dont have huge files. Or even put different types of logs in different folders to keep it more structured ::)

Offline DorkeyDear

  • Veteran
  • *****
  • Posts: 1507
  • I also go by Curt or menturi
Re: Script log files location
« Reply #4 on: February 06, 2011, 11:38:58 am »
My current setup for log names in my project is simply type is the filename (e.g. debug.log) and inside the file I prefix all lines with the date, time, and type (YY-MM-DD HH:MM:SS.XXX TYPE). I include TYPE since some log types belong in multiple files (that way debug includes general notices as well, easier to see what is happening when).
My current debug.log file is 9614 KB in size, separating it by date will make file sizes small, but many more files. I think I will change this behavior to include date and type in filename.

Another aside question: Do you think i should make sub-directories for different types of logs, or put them all in the same directory (./logs/SCRIPT_NAME/debug/DATE.log or ./logs/SCRIPT_NAME/debug DATE.log)?

Also, (another aside question) is there a preference to file extension of log files? I tend towards .log files, but .txt is also used. It doesn't make much of a difference, but .log file extension may not be set and it could be annoying for some people. It also seems as though the extension reflects what's inside, so .log makes more sense in that perspective.
« Last Edit: February 06, 2011, 11:41:29 am by DorkeyDear »