AMIA ARCHIVE
https://www.amiaworld.net/phpBB3/

[Linux Clients Only] I found a chatlog rotator
https://www.amiaworld.net/phpBB3/viewtopic.php?f=2&t=84399
Page 1 of 1

Author:  NiwatoriKami [ Sat, Nov 21 2015, 0:53 AM ]
Post subject:  [Linux Clients Only] I found a chatlog rotator

This might be helpful for those who need to rotate the chatlogs and server messages on the Linux Client. I found a discussion on reddit and found a script that can do this.

There are some caveats however:

    1. If the server crashes, the script doesn't detect this and seems to keep on logging when re-entering the server without exiting the client

    2. The script needs to run before launching the client once for it to run in the background. You have to repeat this step after restarting your PC or have it run at boot.

    3. You must have the utility called entr installed. Normally, this can be installed via sudo apt-get install entr

How to create and install:

    Step 1. Create an empty text file such as NWNchatlogrotator.sh and copy-paste the code below.

    Chatlog Rotator Script
    Code:
    #!/usr/bin/env bash

    export NWN_DIRECTORY=(insert the location of the NWN directory here without the parentheses such as /home/username/NeverwinterNights)
    export LOG_DIRECTORY="$NWN_DIRECTORY/logs"
    export LOG_FILE="$LOG_DIRECTORY/nwclientLog1.txt"

    rotate_log() {
      entr bash -c '
      cp "$LOG_FILE" "$LOG_DIRECTORY/$(date +%d-%m-%G-%H-%M-%S.log)"
      echo "Log rotated!"
      '
    }

    find "$LOG_DIRECTORY" -name "nwclientLog1.txt" | rotate_log


    Step 2. Save the file to your NWN directory

    Step 3. You have to make the file created an executable by going into terminal and go to your NWN directory and type chmod u+x ~/(name you gave the chatlog rotator script such as NWNchatlogrotator.sh)

    Step 4. Run the script before loading your game client

Hope this helps fellow Linux client users.

Author:  Gravemaskin [ Sat, Nov 21 2015, 9:26 AM ]
Post subject:  Re: [Linux Clients Only] I found a chatlog rotator

Or just have a bat file..

@ECHO OFF
START /w nwmain.exe
FOR /F "TOKENS=1-3 DELIMS=/ " %%a IN ("%date%") DO SET dd=%%a&SET mm=%%b&SET yy=%%c
FOR /F "TOKENS=1-3 DELIMS=:." %%a IN ("%time%") DO SET hh=%%a&SET tt=%%b&SET ss=%%c
COPY "logs\nwclientLog1.txt" "logs\NWNLOG%yy%-%mm%-%dd%_%hh%h%tt%m%ss%s.txt"

Page 1 of 1 All times are UTC
Powered by phpBB® Forum Software © phpBB Group
http://www.phpbb.com/