Chat Logging

Started by FleetingHeart, May 02, 2010, 07:09:46 PM

Previous topic - Next topic

FleetingHeart

Activating Chat Logging

Quote from: SnoteyeTo activate chat logging,  go to your NWN directory, open nwnplayer.ini and, under [Game Options], add  the line ClientChatLogging=1.  This will save your logs to the \logs folder inside the NWN directory.
 
Note, this will only log chat text. If you want combat feedback and  system messages logged too, change ClientEntireChatWindowLogging to 1 as well.


Auto Chat Log Rotation

What it does:
1) Appends new logs to old ones upon quitting the game, thus keeping one neat and tidy log file with all information. Each log is separated by a time stamp.

2) Effectively keeps separate logs for different characters.

3) Allows direct connecting to the server, effectively replacing your NWN shortcut.

If you would like to use this to connect to other servers, simply change the following code segment.

WshShell.Run NWN_PATH & "\nwmain.exe [B]+connect efu.us.to[/B]",,TRUEOr, to disable direct connect simply change it to this:

WshShell.Run NWN_PATH & "\nwmain.exe",,TRUE

Usage

Copy and paste the code below into a text file. Save it as ChatLog.vbs and place it in your NWN directory. Now, create a new shortcut to this script.

You'll now want to edit the shortcut by adding a name after the script file. Whatever you place here will be used as the name of the permanent log file. For instance:

C:\NeverwinterNights\NWN\ChatLog.vbs "OO NA"

Will result in a log file named "OO NA.log"

Quotes are only needed if you want a space to appear in the name.

C:\NeverwinterNights\NWN\ChatLog.vbs Oona

Would create a log named "Oona.log"

'Dynamic Log Naming variables
dim LOG_NAME
Dim args_index
Dim command_line_args
Set command_line_args = wscript.Arguments

LOG_NAME = command_line_args(args_index) & ".log"

'Folder where NWN is installed
CONST NWN_PATH = "C:\NeverwinterNights\NWN"

'Start NWN and halts script execution until NWN is closed
Dim WshShell
set WshShell = WScript.CreateObject("WScript.Shell")
WshShell.Run NWN_PATH & "\nwmain.exe +connect efu.us.to",,TRUE

'Blah :-)
Dim fso: set fso = CreateObject("Scripting.FileSystemObject")
Dim sTargetFile, datLastModified, nwnSessionLog, nwnLogFile
Set nwnSessionLog = fso.OpenTextFile(NWN_PATH & "\logs\nwclientLog1.txt",1)


'If a character log file exists
If fso.FileExists(NWN_PATH & "\logs\" & LOG_NAME) Then
    Set nwnLogFile = fso.OpenTextFile(NWN_PATH & "\logs\" & LOG_NAME,8)
    'If a session log file exists
    Else
    Set nwnLogFile = fso.CreateTextFile(NWN_PATH & "\logs\" & LOG_NAME)
End If

If fso.FileExists(NWN_PATH & "\logs\nwclientlog1.txt") Then

   'And if it's bigger then 0
   If fso.GetFile(NWN_PATH & "\logs\nwclientlog1.txt").Size > 0 Then
     
      'Initialize variable to contain Line Break with Date and Time of last modification.
      datLastModified = fso.GetFile(NWN_PATH & "\logs\nwclientlog1.txt").DateLastModified  
      lineBreak =  Year(datLastModified) & "_" & Right("00" & Month(datLastModified),2) & "_" & Right("00" & Day(datLastModified),2) & "_" & Right("00" & Hour(datLastModified),2) & Right("00" & Minute(datLastModified),2)
     
      'Write Log Break Line
      nwnLogFile.WriteLine("-------------------- " & lineBreak & " --------------------")
     
      'Concatonate session log into complete log
      TextReadAll=nwnSessionLog.ReadAll
      nwnLogFile.Write TextReadAll
      nwnSessionLog.Close
      nwnLogFile.Close
     
   End If
End If
And finally, an  alternative script.
 
This one accesses the registry to find  the location of NWN. If this makes you uncomfortable don't use i!
 
It is perfectly safe, however, and only reads the registry. It will not  delete or add any entries.
 
 
Dim WshShell
set WshShell = WScript.CreateObject("WScript.Shell")
dim logName
Dim args_index  
Dim command_line_args  
Set command_line_args = wscript.Arguments
'retrieves Log File Name based on command line input
logName = command_line_args(args_index) & ".log"
 
'Poll Registry for NWN location.
nwnPath = WshShell.RegRead(  "HKEY_LOCAL_MACHINE\SOFTWARE\BioWare\NWN\Neverwinter\Location" )
 
'Start NWN and halts script execution until NWN is closed
WshShell.Run nwnPath & "\nwmain.exe +connect efu.us.to",,TRUE
 
'Blah :-)
Dim fso: set fso = CreateObject("Scripting.FileSystemObject")
Dim sTargetFile, datLastModified, nwnSessionLog, nwnLogFile
Set nwnSessionLog = fso.OpenTextFile(nwnPath &  "\logs\nwclientLog1.txt",1)
 
 
'If a character log file exists
If fso.FileExists(nwnPath & "\logs\" & logName) Then
   Set nwnLogFile = fso.OpenTextFile(nwnPath & "\logs\" &  logName,8)
   'If a session log file exists
   Else
   Set nwnLogFile = fso.CreateTextFile(nwnPath & "\logs\" &  logName)
End If
 
If fso.FileExists(nwnPath & "\logs\nwclientlog1.txt") Then
 
   'And if it's bigger then 0
   If fso.GetFile(nwnPath & "\logs\nwclientlog1.txt").Size > 0  Then
       
      'Initialize variable to contain Line Break with Date and Time of  last modification.
      datLastModified = fso.GetFile(nwnPath &  "\logs\nwclientlog1.txt").DateLastModified    
      lineBreak =  Year(datLastModified) & "_" & Right("00"  & Month(datLastModified),2) & "_" & Right("00" &  Day(datLastModified),2) & "_" & Right("00" &  Hour(datLastModified),2) & Right("00" &  Minute(datLastModified),2)
       
      'Write Log Break Line
      nwnLogFile.WriteLine("-------------------- " & lineBreak &  " --------------------")
       
      'Concatonate session log into complete log
      TextReadAll = nwnSessionLog.ReadAll
      nwnLogFile.Write TextReadAll
      nwnSessionLog.Close
      nwnLogFile.Close
       
   End If
End If

Aethereal

A reminder that when copying the code, don't use the standard forum text as the smiley face emoticons do not convert...

e.g.

logName,8)
---
'Even life eternal is not time enough to see, all the folly and despair of poor Humanity.' - [url=https://www.youtube.com/watch?v=OJAoaCHdTJY]To Life - A Shoggoth on the Roof[/url]

It is through Art, and through Art only, that we can realise our perfection.

Joe Desu

T1 be clear to someone who has never gotten this to work, how many steps are involved to do this?

1. Set ClientChatLogging=1 Or ClientEntireChatWindowLogging=1

2. Copy and paste the code below into a text file. Save it as ChatLog.vbs

3. ???

4. ????

...or are two steps only required?

Kinslayer988

<SkillFocuspwn> no property developers among men only brothers

Aethereal

Step 1 will result in a logfile titled: "nwclientLog1.txt" within your NeverwinterNights\NWN\logs folder. The issue we face there is that the nwclientLog1.txt is always wiped when a new neverwinter nights client session is started.

This can obviously be remedied by always saving your log file in an alternate document after each session - but this can become tedious. To remedy the tedium is why we have the excellent Auto Chat Log Rotation scripts.

The main error I was having was that line 7: of the first code and line 8 of the alternate code had the issue of: "Subscript out of range."

LOG_NAME = command_line_args(args_index) & ".log"

As I perused the code I thought to myself, wait... what? Why must we call upon "command_line_args(args_index)" to create our Logfile name?

And so I simply edited in the name I wanted for my log file as follows:

LOG_NAME = "EFUA Chatlog.txt"

Thus, I present a refined two step process:

[hide=Step 1]To activate chat logging, go to your NWN directory, open nwnplayer.ini and, under [Game Options], add the line ClientChatLogging=1. This will save your logs to the \logs folder inside the NWN directory.

Note, this will only log chat text. If you want combat feedback and system messages logged too, change ClientEntireChatWindowLogging to 1 as well.[/hide]
Copy and paste the code below into a text file. Save it as ChatLog.vbs and place it in your NWN directory. Now, create a new shortcut to this script - use this shortcut to directly connect to EFU:A from now on to ensure your logfile is maintained.
[hide=Step 2]'Dynamic Log Naming variables
dim LOG_NAME
Dim args_index
Dim command_line_args
Set command_line_args = wscript.Arguments

LOG_NAME = "EFUA Chatlog.txt"

'Folder where NWN is installed
CONST NWN_PATH = "C:\Games\NeverwinterNights\NWN"

'Start NWN and halts script execution until NWN is closed
Dim WshShell
set WshShell = WScript.CreateObject("WScript.Shell")
WshShell.Run NWN_PATH & "\nwmain.exe +connect efu.us.to",,TRUE

'Blah :-)
Dim fso: set fso = CreateObject("Scripting.FileSystemObject")
Dim sTargetFile, datLastModified, nwnSessionLog, nwnLogFile
Set nwnSessionLog = fso.OpenTextFile(NWN_PATH & "\logs\nwclientLog1.txt",1)


'If a character log file exists
If fso.FileExists(NWN_PATH & "\logs\" & LOG_NAME) Then
    Set nwnLogFile = fso.OpenTextFile(NWN_PATH & "\logs\" & LOG_NAME,8)
    'If a session log file exists
    Else
    Set nwnLogFile = fso.CreateTextFile(NWN_PATH & "\logs\" & LOG_NAME)
End If

If fso.FileExists(NWN_PATH & "\logs\nwclientlog1.txt") Then

   'And if it's bigger then 0
   If fso.GetFile(NWN_PATH & "\logs\nwclientlog1.txt").Size > 0 Then
     
      'Initialize variable to contain Line Break with Date and Time of last modification.
      datLastModified = fso.GetFile(NWN_PATH & "\logs\nwclientlog1.txt").DateLastModified  
      lineBreak =  Year(datLastModified) & "_" & Right("00" & Month(datLastModified),2) & "_" & Right("00" & Day(datLastModified),2) & "_" & Right("00" & Hour(datLastModified),2) & Right("00" & Minute(datLastModified),2)
     
      'Write Log Break Line
      nwnLogFile.WriteLine("-------------------- " & lineBreak & " --------------------")
     
      'Concatonate session log into complete log
      TextReadAll=nwnSessionLog.ReadAll
      nwnLogFile.Write TextReadAll
      nwnSessionLog.Close
      nwnLogFile.Close
     
   End If
End If[/hide]

As mentioned by FleetingHeart, the following still applies:

Quote from: FleetingHeart;1805503) Allows direct connecting to the server, effectively replacing your NWN shortcut.

If you would like to use this to connect to other servers, simply change the following code segment.

WshShell.Run NWN_PATH & "\nwmain.exe [B]+connect efu.us.to[/B]",,TRUEOr, to disable direct connect simply change it to this:

WshShell.Run NWN_PATH & "\nwmain.exe",,TRUE

Hopefully that should resolve any problems for those who were unable to work the original scripts.
---
'Even life eternal is not time enough to see, all the folly and despair of poor Humanity.' - [url=https://www.youtube.com/watch?v=OJAoaCHdTJY]To Life - A Shoggoth on the Roof[/url]

It is through Art, and through Art only, that we can realise our perfection.

AClockworkMelon

There is no [Game Options] section in my .ini file. Can I just add it in myself? If so, does it matter where I put it?

Aethereal

Quote from: AClockworkMelon;250667There is no [Game Options] section in my .ini file. Can I just add it in myself? If so, does it matter where I put it?

I would advise checking again. Remember the file name is nwnplayer.ini not nwn.ini. [Game Options] is the first line.
---
'Even life eternal is not time enough to see, all the folly and despair of poor Humanity.' - [url=https://www.youtube.com/watch?v=OJAoaCHdTJY]To Life - A Shoggoth on the Roof[/url]

It is through Art, and through Art only, that we can realise our perfection.

AClockworkMelon

Quote from: Aethereal;250792Remember the file name is nwnplayer.ini not nwn.ini. [Game Options] is the first line.
Ah, that was my problem! Thanks. :)

Aethereal

Having reinstalled the game client (don't ask.) I would recommend sticky status for this thread, as chat logging is an incredibly useful tool, especially for accessing text for later perusal or publication ICly.
---
'Even life eternal is not time enough to see, all the folly and despair of poor Humanity.' - [url=https://www.youtube.com/watch?v=OJAoaCHdTJY]To Life - A Shoggoth on the Roof[/url]

It is through Art, and through Art only, that we can realise our perfection.