Jump to content

Logs: Difference between revisions

From Arelith Wiki
Zanithar (talk | contribs)
Batch files for Windows: updated steam batch directions as WMIC was deprecated in Win11
Updated Linux Shellscript to new version
Line 114: Line 114:
:And if servervar is set to 1 then it automatically connects to the server.
:And if servervar is set to 1 then it automatically connects to the server.


==Bash files for Linux (and possibly macOS)==
==Shell Scripts for Linux (and possibly macOS)==


Details for making .bash files that rotate logs.
A functioning log rotator using the shell script (bash) for Linux, possibly can also work on macOS, but this is untested.


===Using Steam install===
=== Explanation ===
This is a very rudimentary script that will rotate logs automatically. The way this works is by renaming and filing away the client log each time the game runs. This has an advantage of being very lean, as it doesn't wait for a process to complete.


This will normally integrate with Steam to run Neverwinter Nights but you can turn that functionality off by switching ENABLE_STEAM to "false". You can also run it without Steam running and, if your NWN_LAUNCH variable is set correctly, it will launch the game directly.
It will sort all the files by year, month, and day. For example: 2025/07-July/11-Friday.


This is a very rudimentary script that will rotate logs automatically. The way this works is by renaming and filing away the client log each time the game runs. This has an advantage of being very lean, as it doesn't wait for a process to complete. This does mean that you'll have to run the .sh script in lieu of launching Neverwinter Nights normally.
=== Usage ===
Put the script wherever you wish. I've put in ~/.local/bin.  


It will sort all the files by year and month, so you'll see /2024/02/<LogFile> in your directories. This is preferable as it makes it less of a blob compared to other log rotators who will save all logs in the same folder.
If using Steam, add this to your launch arguments for Neverwinter Nights:


The top 4 variables need to point in the right directions:
<path_to_script>/nwnlogrotator.sh && %command%
*NWN_LAUNCH
:Point this to where your game process launches out of. Don't edit anything past /steamapps as that should be correct.
*LOG_INPUT_FOLDER
:Point this to where your logs are first created.
*LOG_OUTPUT_FOLDER
:Point this where you want the log files to dump.
*LOG_MIN_LINES
:Set this the minimum number of lines the log needs to be before it will create a dump. I keep this at 100 so it doesn't copy logs for things like quick login-logout scenarios. You could increase this or lower this as you prefer.
*ENABLE_STEAM
:Set this to "false" if you want no Steam integration.


<nowiki>
If you're using Mangohud or need more arguments added, put it after the &&.
NWN_LAUNCH=<path-to-steam-library>/steamapps/common/Neverwinter\ Nights/bin/linux-x86
LOG_INPUT_FOLDER=~/.local/share/Neverwinter\ Nights/logs
LOG_OUTPUT_FOLDER=~/Documents/nwn-logs
LOG_MIN_LINES=100
ENABLE_STEAM=true


input=$LOG_INPUT_FOLDER/nwclientLog1.txt
If you're not using Steam, you'll need to run the script before you launch the game. You can Make a small shell script to do this for you if you wish.
line_count=$(wc -l < "$input")
 
if [ "$line_count" -ge "$LOG_MIN_LINES" ];
=== Script ===
then
There are 2 variables that need to be pointed in the right directions:
year=$(date -r $input +"%Y")
 
month=$(date -r $input +"%m")
* SRC_IN_DIR
day=$(date -r $input +"%d")
: Point this to where your log files normally spawn. The default should be correct.
hour=$(date -r $input +"%H")
* OUT_DIR
minute=$(date -r $input +"%M")
: Point this to where you want the rotated logs to output.
second=$(date -r $input +"%S")
 
outputfolder=$LOG_OUTPUT_FOLDER/$year/$month/
<pre>
outputname=$year-$month-$day-$hour:$minute:$second.txt
#!/bin/bash
echo -e "Copying $input to $outputfolder as $outputname"
 
mkdir -p $outputfolder && mv $input $outputfolder$outputname
# Config
else
SRC_IN_DIR="${HOME}/.local/share/Neverwinter Nights/logs"
echo "Skipping log copy. Lines in log are fewer than $LOG_MIN_LINES."
OUT_DIR="${HOME}/Documents/NWN-Logs"
OUT_EXT="log"
ACTION_LOG="${OUT_DIR}/rotator-actions.log"
 
# Create the directory if it doesn't exist
if [ ! -d "${OUT_DIR}" ]; then
  mkdir -pv "${OUT_DIR}"
fi
fi


if pgrep -x "steam" >/dev/null && $ENABLE_STEAM = "true"
# Start log file
then
echo "--------------------------" > "${ACTION_LOG}"
echo "Steam is running. Running through Steam."
echo "NWN LOG ROTATOR BY vickydotbat" >> "${ACTION_LOG}"
nohup steam steam://rungameid/704450 &
echo "" >> "${ACTION_LOG}"
else
echo "Source Directory: ${SRC_IN_DIR}" >> "${ACTION_LOG}"
cd "$NWN_LAUNCH"
echo "Output Location: ${OUT_DIR}" >> "${ACTION_LOG}"
echo "Steam is not running or is disabled. Running directly."
echo "Output Extension: ${OUT_EXT}" >> "${ACTION_LOG}"
nohup ./nwmain-linux &
echo "--------------------------" >> "${ACTION_LOG}"
fi
 
sleep 20
# Scan src directory
exit
for f in "${SRC_IN_DIR}"/*; do
</nowiki>
    if [ ! -f "${f}" ]; then exit; fi
 
    echo "Operating on ${f}" >> "${ACTION_LOG}"
    srcname="${f##*/}" && srcname="${srcname%.*}"
   
    rB=$(date -r "${f}" +"%B")              # Modified Month Name
    rA=$(date -r "${f}" +"%A")              # Modified Day Name
    rY=$(date -r "${f}" +"%Y")              # Modified Year Num
    rm=$(date -r "${f}" +"%m")              # Modified Month Num
    rd=$(date -r "${f}" +"%d")              # Modified Day Num
    rH=$(date -r "${f}" +"%H")              # Modified Hour Num
    rM=$(date -r "${f}" +"%M")              # Modified Minute Num
    rS=$(date -r "${f}" +"%S")              # Modified Second Num
 
    dest="${OUT_DIR}/${rY}/${rm}-${rB}/${rd}-${rA}"
    echo "Destination Directory: ${dest}" >> "${ACTION_LOG}"
    if [ ! -d "${dest}" ]; then
        mkdir -pv "${dest}" >> "${ACTION_LOG}"
    fi
 
    outname="${rY}-${rm}-${rd}_${rH}${rM}${rS}_${srcname}.${OUT_EXT}"
    echo "Translating ${srcname} into ${outname}" >> "${ACTION_LOG}"
    mv -v "${f}" "${dest}/${outname}" >> "${ACTION_LOG}"
 
    notify-send -t 4000 "New logfile generated: ${outname}"
 
    echo "" >> "${ACTION_LOG}"
done
</pre>


[[Category:Help Desk]]
[[Category:Help Desk]]

Revision as of 11:59, 11 July 2025

Chat Logs
Arelith
Wiki
Character Creation
Creation (New Players Guide)
Race - Deity - Class
Gifts - Backgrounds - Alignment
Marks - Epic Sacrifice
Customization - Head List - Builds
Character Systems
Description - Disguise / Covered
Languages - Experience - Quests
Pickpocket - Rest - Role Play Bonus
Death - Lycanthropy - Investigate
Sequencers - Runic Sequencers
World Systems
Settlements - Factions
Quarters - Shops - Taverns - Banks
Riding - Sailing - Boons
Communication - Portals
Time - Containers/Bags
Radiant Heart - Assassin's Guild
Sencliff's Pirates
Item Creation Systems
Alchemy - Art Craft - Carpentry
Herb - Smith - Tailor
Dweomercraft - Runes
Armor
Weapons - Melee / Ranged / Siege
Resources - Poison
Arelith Changes
Classes - Skills - Feats - Trap
Summons - Familiar Reskins
Spells (list) - Misc
Help
Rules - Roleplay - Maps
Console Commands
Common Bugs - Staff
Support Tickets - Character Remake
[The Astrolabe]

Chat logs are a great way to preserve RP, study combat, and have logs for peace of mind in case of report-able issues.


Turn on logging in NWN EE

How to turn on logging in NWN EE.

Choose This Option

Batch files for Windows

Details for making .bat files.

Using steam install, not running through steam

Has the advantage of automatic log re-naming after quitting, but doesn't use Steam Workshop subscriptions

@setlocal enableextensions enabledelayedexpansion @echo off ::Your NWNL:EE docoument directory on the next line, the location of your logs directory and nwnplayer.ini set EEDocDir="C:\Users\<Your Username Here>\Documents\Neverwinter Nights" ::Your EE nwmain.exe install directory on the next line set EEInstallDir="C:\Program Files (x86)\Steam\steamapps\common\Neverwinter Nights\bin\win32" echo Select a Server echo 1. NWN: EE Distant Shores echo 2. NWN: EE Cordor and Planes echo 3. NWN: EE Surface echo 4. NWN: EE Underdark echo 5. NWN: EE Guldorand echo 6. NWN: Main echo 7. NWN: PGCC set /p servervar= Server Number: if %servervar% lss 8 ( set logdir=%EEDocDir% cd /D %EEInstallDir% if %servervar% == 1 start /wait nwmain.exe +connect game.nwnarelith.com:5121 if %servervar% == 2 start /wait nwmain.exe +connect game.nwnarelith.com:5122 if %servervar% == 3 start /wait nwmain.exe +connect game.nwnarelith.com:5123 if %servervar% == 4 start /wait nwmain.exe +connect game.nwnarelith.com:5124 if %servervar% == 5 start /wait nwmain.exe +connect game.nwnarelith.com:5125 if %servervar% == 6 start /wait nwmain.exe if %servervar% == 7 start /wait nwmain.exe +connect arena.arelith.com:5123 ) for /f "tokens=2 delims==" %%a in ('wmic OS Get localdatetime /value') do set "dt=%%a" set "YYYY=%dt:~0,4%" & set "MM=%dt:~4,2%" & set "DD=%dt:~6,2%" set "HH=%dt:~8,2%" & set "Min=%dt:~10,2%" & set "Sec=%dt:~12,2%" set TODAY=%YYYY%-%MM%-%DD% set NOW=%HH%-%Min%-%Sec% move %logdir%\logs\nwclientLog1.txt %logdir%\logs\log-%TODAY%-%NOW%.txt

Using Steam install running through steam

Advantage of using Steam Workshop subscriptions and Steam overlay, but sludgy implementation of automatic chat logging

@echo off
for /f %%i in ('powershell -NoProfile -Command "Get-Date -Format yyyy-MM-dd_HH-mm-ss"') do set datetime=%%i
echo *** Starting Neverwinter Nights ***

    START /WAIT steam://rungameid/704450

    timeout /t 5 /nobreak > nul

    :loop
    timeout /t 1 /nobreak > nul
    tasklist /fi "imagename eq nwmain.exe" |find ":" > nul
    if errorlevel 1 goto loop

echo *** Neverwinter Nights Terminated ***

echo *** Processing Logs ***

::BOTH WITHOUT QUOTES
::Your NWNL:EE docoument directory on the next line, the location of your logs directory and nwnplayer.ini
set EEDocDir=NWN DOCUMENTS FOLDER HERE
::Your EE nwmain.exe install directory on the next line
set EEInstallDir=STEAMAPPS NWN WIN32 DIRECTORY HERE

  set logdir=%EEDocDir%
  cd /D %EEInstallDir%
  ".\Neverwinter Nights Enhanced Edition.url"

/wait

set "TODAY=%datetime:~0,10%"
set "NOW=%datetime:~11%"
move "%logdir%\logs\nwclientLog1.txt" "%logdir%\logs\log-%TODAY%-%NOW%.txt"


Explaining the commands

  • @echo off
That turns off the unsightly file path.
  • cd C:\Program Files (x86)\Steam\steamapps\common\Neverwinter Nights\bin\win32
Make sure you have this, the batch doesn't seem to work right unless you set the path before.
  • echo
This is the text that you see.
  • set /p servervar= Server Number:
This is the multiple choice script.
server is the variable a variable and has to be set before anything can be done.
  • if %servervar% == 1 start nwmain.exe +connect game.arelith.com:5121
This called on the servervar variable (HAS to have % on either sides I believe)
And if servervar is set to 1 then it automatically connects to the server.

Shell Scripts for Linux (and possibly macOS)

A functioning log rotator using the shell script (bash) for Linux, possibly can also work on macOS, but this is untested.

Explanation

This is a very rudimentary script that will rotate logs automatically. The way this works is by renaming and filing away the client log each time the game runs. This has an advantage of being very lean, as it doesn't wait for a process to complete.

It will sort all the files by year, month, and day. For example: 2025/07-July/11-Friday.

Usage

Put the script wherever you wish. I've put in ~/.local/bin.

If using Steam, add this to your launch arguments for Neverwinter Nights:

<path_to_script>/nwnlogrotator.sh && %command%

If you're using Mangohud or need more arguments added, put it after the &&.

If you're not using Steam, you'll need to run the script before you launch the game. You can Make a small shell script to do this for you if you wish.

Script

There are 2 variables that need to be pointed in the right directions:

  • SRC_IN_DIR
Point this to where your log files normally spawn. The default should be correct.
  • OUT_DIR
Point this to where you want the rotated logs to output.
#!/bin/bash

# Config
SRC_IN_DIR="${HOME}/.local/share/Neverwinter Nights/logs"
OUT_DIR="${HOME}/Documents/NWN-Logs"
OUT_EXT="log"
ACTION_LOG="${OUT_DIR}/rotator-actions.log"

# Create the directory if it doesn't exist
if [ ! -d "${OUT_DIR}" ]; then
  mkdir -pv "${OUT_DIR}"
fi

# Start log file
echo "--------------------------" > "${ACTION_LOG}"
echo "NWN LOG ROTATOR BY vickydotbat" >> "${ACTION_LOG}"
echo "" >> "${ACTION_LOG}"
echo "Source Directory: ${SRC_IN_DIR}" >> "${ACTION_LOG}"
echo "Output Location: ${OUT_DIR}" >> "${ACTION_LOG}"
echo "Output Extension: ${OUT_EXT}" >> "${ACTION_LOG}"
echo "--------------------------" >> "${ACTION_LOG}"

# Scan src directory
for f in "${SRC_IN_DIR}"/*; do
    if [ ! -f "${f}" ]; then exit; fi

    echo "Operating on ${f}" >> "${ACTION_LOG}"
    srcname="${f##*/}" && srcname="${srcname%.*}"
    
    rB=$(date -r "${f}" +"%B")              # Modified Month Name
    rA=$(date -r "${f}" +"%A")              # Modified Day Name
    rY=$(date -r "${f}" +"%Y")              # Modified Year Num
    rm=$(date -r "${f}" +"%m")              # Modified Month Num
    rd=$(date -r "${f}" +"%d")              # Modified Day Num
    rH=$(date -r "${f}" +"%H")              # Modified Hour Num
    rM=$(date -r "${f}" +"%M")              # Modified Minute Num
    rS=$(date -r "${f}" +"%S")              # Modified Second Num

    dest="${OUT_DIR}/${rY}/${rm}-${rB}/${rd}-${rA}"
    echo "Destination Directory: ${dest}" >> "${ACTION_LOG}"
    if [ ! -d "${dest}" ]; then
        mkdir -pv "${dest}" >> "${ACTION_LOG}"
    fi

    outname="${rY}-${rm}-${rd}_${rH}${rM}${rS}_${srcname}.${OUT_EXT}"
    echo "Translating ${srcname} into ${outname}" >> "${ACTION_LOG}"
    mv -v "${f}" "${dest}/${outname}" >> "${ACTION_LOG}"

    notify-send -t 4000 "New logfile generated: ${outname}"

    echo "" >> "${ACTION_LOG}"
done