Most efficient file watch - lavishscript

Discussion of Inner Space

Moderators: Lavish Software Team, Moderators

Post Reply
haunaben
GamingTools Subscriber
Posts: 29
Joined: Fri Jan 09, 2009 6:03 pm

Most efficient file watch - lavishscript

Post by haunaben » Fri Aug 16, 2013 9:52 am

I'm building a kind of timer / countdown bar overlay to use in EQ1 to show spell duration, resuse timers, etc. It will simply read log file lines and update based on string matches. (yes I know about GTT but I want graphical bars and ability to monitor multiple files without multiple GTT's running).

I'm trying to determine the best (efficient) way to open multiple log files and watch them for new lines.

If I did this in lavishscript it would basically be:

load a script w/ main function that:

- opnens readonly all my log files (3 or 4 of them)
- in while loop
--- read line
--- if not EOF then parse read line
------ set any properties to update UI
---update my UI bars that are active and update based on last line parsed

Is this the right approach for Lavishscript? Should I do any kind of counter / wait in the while loop to prevent excessive processing (like ensure the loop only runs once every 100ms or so)?

Or .. is there some other approach I should use for this to be done efficiently?

Lax
Owner
Posts: 6634
Joined: Fri Jun 18, 2004 6:08 pm

Post by Lax » Fri Aug 16, 2013 12:06 pm

There is an efficient real-time log parsing method available in Inner Space. Here's a working proof-of-concept script: http://pastebin.com/gm3BV4Jj

haunaben
GamingTools Subscriber
Posts: 29
Joined: Fri Jan 09, 2009 6:03 pm

Post by haunaben » Fri Aug 16, 2013 5:28 pm

sweet thanks!!

haunaben
GamingTools Subscriber
Posts: 29
Joined: Fri Jan 09, 2009 6:03 pm

Post by haunaben » Sat Aug 17, 2013 7:50 am

Ok I have most of what I need working.

Is there any way to load specific log files? It does not matter which file I pass to RegisterLog, it always uses the log file of the current character for that IS session. For example, all 3 of the following produce the same result and always reads "MyCharacter.txt":

LogReader:RegisterLog["logs/eqlog_MyCharacter.txt","EQ1_ChatLog"]
LogReader:RegisterLog["logs/eqlog_SomeOtherCharacter.txt","EQ1_ChatLog"]
LogReader:RegisterLog["logs/eqlog_*.txt","EQ1_ChatLog"]
LogReader:RegisterLog["","EQ1_ChatLog"]

I didn't see any virtual files mapped for log files, but maybe there is some other redirection happening?

Lax
Owner
Posts: 6634
Joined: Fri Jun 18, 2004 6:08 pm

Post by Lax » Sat Aug 17, 2013 8:06 am

This feature only works for files written by the current process, as the file is being written to.

If you need it from your other characters, this processing will need to occur within that character's session

haunaben
GamingTools Subscriber
Posts: 29
Joined: Fri Jan 09, 2009 6:03 pm

Post by haunaben » Sat Aug 17, 2013 8:21 am

Ahh gotcha. I'll have to rework my stuff a little .. in a way it's cleaner though because each toon will have their own triggers file.

Lax
Owner
Posts: 6634
Joined: Fri Jun 18, 2004 6:08 pm

Post by Lax » Sun Aug 18, 2013 1:52 pm

Thanks for posting your results over on isboxer.com :)

ismods.com could use some content like this as well, if you're interested. The site is a bit under-utilized right now but this is exactly what belongs there

haunaben
GamingTools Subscriber
Posts: 29
Joined: Fri Jan 09, 2009 6:03 pm

Post by haunaben » Sun Aug 18, 2013 4:19 pm

You bet. I put the post on ismods as well. I've used innerspace well before isboxer and still use a lot of my old scripts. I'll put some other snippets up there as well.

haunaben
GamingTools Subscriber
Posts: 29
Joined: Fri Jan 09, 2009 6:03 pm

Post by haunaben » Wed Aug 21, 2013 8:01 am

Any chance of a transparent parameter for AddTrigger? (or is there a way to do it with current implementation)

example usage: http://pastebin.com/bNZ3mZpy

I'd like to control the proliferation of atoms ) If it gets too unwieldy I might build a configurator to generate my files.

On that note .. any thought given to extensibility plugins for isboxer that could generate other files based on the isboxer config?

Pizani
GamingTools Subscriber
Posts: 2
Joined: Fri Dec 23, 2011 3:27 pm

Post by Pizani » Fri Oct 10, 2014 4:37 pm

Sorry for the necro of this old thread, but this is where I got all the info I am asking questions about.

I have used ISboxer for years, and decided I wanted to try out the TTS in your example. The problem is I can't get it to read the log files as they change.

I tried the various name combinations mentioned above. The file name format is currently "eqlog_charname_servername.txt", and I tried adjusting for that. I ran the script as a direct copy from the sample provided, both from the Uplink console and from the console in the game itself (from the instance "is1"). In game, the log file is on and being updated as expected.

How do I determine which file it is looking at (ie to confirm the path and file format is correct)? Or any other ideas on what might be wrong?

Thanks!

Lax
Owner
Posts: 6634
Joined: Fri Jun 18, 2004 6:08 pm

Post by Lax » Sun Oct 12, 2014 7:44 am

Pizani wrote:Sorry for the necro of this old thread, but this is where I got all the info I am asking questions about.

I have used ISboxer for years, and decided I wanted to try out the TTS in your example. The problem is I can't get it to read the log files as they change.

I tried the various name combinations mentioned above. The file name format is currently "eqlog_charname_servername.txt", and I tried adjusting for that. I ran the script as a direct copy from the sample provided, both from the Uplink console and from the console in the game itself (from the instance "is1"). In game, the log file is on and being updated as expected.

How do I determine which file it is looking at (ie to confirm the path and file format is correct)? Or any other ideas on what might be wrong?

Thanks!
The log reader supports wildcards. The example script (http://pastebin.com/gm3BV4Jj) should work without modifications, using a wildcard.
LogReader:RegisterLog["logs/eqlog_*.txt","EQ1_ChatLog"]

The * matches any charname_servername.txt.
How do I determine which file it is looking at (ie to confirm the path and file format is correct)?
The event attached to the log reader fires when the file is open and specifies the filename.

Code: Select all

atom OnEQ1ChatLog(string filename, string action, string text)
{
        echo "OnEQ1ChatLog["${filename.Escape}","${action.Escape}","${text.Escape}"]"
}
So if you have the example running -- bearing in mind you must run the script in the game itself and not in the Inner Space Uplink -- and then go log into a toon, it should then open the log file for writing, and then the in-game IS console should spit out something like.. OnEQ1ChatLog["logs/eqlog_antonius_someguy.txt","open"]

Or any other ideas on what might be wrong?
Share your actual code and I can give more speficic tips. Also if you're running this in the Uplink that's not going to work, the log reader works based on the log files open by the current process.



p.s. I would prefer ismods.com for this type of question but that's okay. Here's an example of a script, at ismods.com, based on the stuff in this thread: http://ismods.com/phpBB3/viewtopic.php?f=5&t=29

Pizani
GamingTools Subscriber
Posts: 2
Joined: Fri Dec 23, 2011 3:27 pm

Post by Pizani » Sun Oct 12, 2014 10:25 am

Thanks for the reply, Lax. Here is the code (it's a subset of the examples above so I can actually see a response when the log file changes).

Code: Select all

function main()
    {
            AddTrigger EQ1_OnLoggingEnabled "[@datetime@] Logging to 'eqlog.txt' is now *ON*."

            AddTrigger EQ1_AFKOn "[@datetime@] You are now A.F.K. (Away From Keyboard)."
            AddTrigger EQ1_AFKOff "[@datetime@] You are no longer A.F.K. (Away From Keyboard)."

            LogReader:RegisterLog["logs/eqlog_*.txt","EQ1_ChatLog"]
     
            LavishScript:RegisterEvent[EQ1_ChatLog]
            Event[EQ1_ChatLog]:AttachAtom[OnEQ1ChatLog]
     
            echo <<Test Activated>>

            while 1
            &#123;
                waitframe
            &#125;
     
    &#125;
     
    atom EQ1_OnLoggingEnabled&#40;string _Line, string _DateTime&#41;
    &#123;
            echo EQ1_OnLoggingEnabled[\"$&#123;_Line.Escape&#125;\",\"$&#123;_DateTime.Escape&#125;\"]"
    &#125;
         
    atom EQ1_AFKOn&#40;string _Line, string _DateTime&#41;
    &#123;
            echo EQ1_AFKOn&#40;&#41;
    &#125;
     
    atom EQ1_AFKOff&#40;string _Line, string _DateTime&#41;
    &#123;
            echo EQ1_AFKOff&#40;&#41;
    &#125;
    
    atom OnEQ1ChatLog&#40;string filename, string action, string text&#41;
    &#123;
            echo "OnEQ1ChatLog[\"$&#123;filename.Escape&#125;\",\"$&#123;action.Escape&#125;\",\"$&#123;text.Escape&#125;\"]"
    &#125;
This code is run inside the EQ game instance (NOT from the Uplink console). It all seems easy enough to me, but I don't get a response. File logging is on and starts up when I log in although EQ does not add the line regarding logging being on. I can use "/log on" to create the line in the log file that says
Logging to 'eqlog.txt' is now *ON*.
But no echoed text appears.

I created a new (trash) character for these tests. The log file created is from log in, plus my turning on and off AFK to see if events are firing.

Code: Select all

[Sun Oct 12 07&#58;37&#58;40 2014] You are not currently assigned to an adventure.
[Sun Oct 12 07&#58;37&#58;45 2014] Announcing now off
[Sun Oct 12 07&#58;37&#58;46 2014] Channels&#58; 1=newplayers&#40;4&#41;, 2=General&#40;58&#41;, 3=Necromancer&#40;1&#41;, 4=Faydwer&#40;11&#41;
[Sun Oct 12 07&#58;37&#58;46 2014] Welcome to EverQuest!
[Sun Oct 12 07&#58;37&#58;46 2014] If you need help, click on the EQ Menu button at the bottom of your screen and select the "Help" option.
[Sun Oct 12 07&#58;37&#58;46 2014] You have entered The Steamfont Mountains.
[Sun Oct 12 07&#58;37&#58;47 2014] Your account has one or more rewards waiting to be claimed.  You may use the Claim Window to view and claim your rewards.  Please remember that each reward can only be claimed by a single character on a single server on this account.
[Sun Oct 12 07&#58;37&#58;47 2014] You can claim a veteran reward on this character.  Type /veteranReward to mark this character veteran reward enabled.  Once a character is flagged for veteran rewards they will get all veteran rewards this account is flagged for, and they will automatically get new veteran rewards as this account qualifies for them.
[Sun Oct 12 07&#58;38&#58;07 2014] You are now A.F.K. &#40;Away From Keyboard&#41;.
[Sun Oct 12 07&#58;38&#58;10 2014] You are no longer A.F.K. &#40;Away From Keyboard&#41;.
[Sun Oct 12 07&#58;42&#58;33 2014] Logging to 'eqlog.txt' is now *ON*.
The issue is that it just seems not to see any log file changes. the OnEQ1ChatLog event just does not seem to fire. I am guessing at the cause, but it could be that it is reading from the wrong folder. But to see what folder it is monitoring, I would need the event to fire.

My EQ install path is D:\Games\Everquest\First and the log files are being created in that folder as expected.

InnerSpace is installed to D:\Games\InnerSpace and the scripts are in the "Scripts\Test" subfolder.

The only response I get in the console area is "<<Test Activated>>" upon running the script, as expected.

There doesn't seem to be much that can go wrong, except the folder names. I tried forcing the full folder name as well, with no change.

Thanks for looking at this.

Post Reply