• You've discovered RedGuides 📕 an EverQuest multi-boxing community 🛡️🧙🗡️. We want you to play several EQ characters at once, come join us and say hello! 👋
  • IS THIS SITE UGLY? Change the look. To dismiss this notice, click the X --->

Tip - Fun with Log Files (Linux) (1 Viewer)

Ramius

Member
Joined
Jun 20, 2021
RedCents
135¢

Reading Log Files​

While Windows has a great many tools that can read the Everquest log files and provide some great services, Linux has its own secret weapon: the Unix (and in my case, Bash) shell. With over 50 years of service, the dizzying array of shell tools available will allow you to do just about anything.
But if you think spells and AAs can be hard to manage, the tools of the shell can be seriously arcane. That's why I wanted to write up some fun I had with the shell recently: to share and learn from the others who may be inspired.

NOTE: If you are handle with the Windows Subsystem for Linux (WSL or WSL2), you might be able to get all of this to work on Windows with some tweaks. Even git-bash may come with enough tools to do something interesting. I haven't tested those, though, so I'll stick to addressing Linux here.

There are a lot of things you can do with logs, but this post will focus on alerting. In particular, I wanted to be alerted on my Linux machine if I received a /tell from someone. If I have the game in the background, I don't want to miss a message. This post focuses on tells but it's easy to adapt the script to check for anything present in the log files.

In my other post I showed that I used /opt/wine/mqeq as the Wine prefix, which means the log files are located in /opt/wine/mqeq/drive_c/eq/Logs. When the game is running, and when logs are enabled in game (/log on), you can easily see a running log with the shell command:

Shell:
$ tail -f /opt/wine/mqeq/drive_c/eq/Logs/eqlog_Ramius_eci.txt

What the tail command does with the -f flag is to show the log file as it is being updated. This is nothing to write home about, so bear with me: it gets more interesting.

Highlighting​

Now, while some people find this useful, it's not all that interesting. Let's take it up a level with some custom highlighting.

On my Arch Linux machine, I installed the grc package. This stands for "Generic Colouriser" and allows one to highlight anything in a log file following a pattern using regular expressions.

Take a look at this file:

eq.conf:
regexp=(\w*\s*)tells
color=white,red
-
regexp=\[(\w{3}\s*\w{3}\s*\d{2}\s*\d{2}:\d{2}:\d{2}\s*\d{4})]
color=white,green
-
regexp=(\w*)\stells you
color=blue

Each pair of lines shows a regular expression (which determines what to highlight) and a set of colors (which show how to highlight). While regular expressions are beyond the scope of this post, you just need to know that the part inside the parentheses is what gets highlighted. Everything else on the 'regexp' line is just used for context to find the correct string to match.

The first set highlights the date of the message in green, the second highlights the person who is sending the message, and the third set of values highlights the name of someone sending you a direct tell in blue.

If we save that configuration text to a file called 'eqlog.conf' we can run this command to see the running log, highlighted as tells and other messages come in.

Shell:
$ tail -f /opt/wine/mqeq/drive_c/eq/Logs/eqlog_Dodobird_eci.txt | grcat eq.conf

This results in a pretty nice-looking log that makes relevant details stand out:

2022-04-06-17:44:29-screenshot.png

But let's get some notifications going.

Notifications​

While grc does include a way to run a command on match in the log file, it is not very flexible and does not allow us to send any context from the matched text line to a command, so we are going to write our own shell script that will do the notifications.

eqlog.conf:
 #!/usr/bin/bash

 REGEX=']\s(\w+) tells you'
 while read -r LINE; do
     if [[ $LINE =~ $REGEX ]]
     then
         play ~/Music/alarm.mp3 > /dev/null 2>&1 &
         notify-send -u critical \
             "Message from ${BASH_REMATCH[1]}" "$LINE" \
             -i ~/Pictures/everquest-icon.jpg
         send-telegram $LINE
     fi
 done

Before I discuss this file, I want to point out that I have an alarm sound file and an EQ icon on my disk already, and this script file depends on the libnotify and sox packages to send a desktop notification and play a sound file, respectively. I also have a self-written python script on my hard drive called send-telegram, which will send the arguments to a telegram bot channel that I set up. I won't include that here.

This script uses another regular expression in the REGEX variable. Just like the previous example, the part in the parentheses is something we will use separately. In this case, it is the name of the message sender.

This script reads every line you send to it, and if it matches the regular expression it executes the code block. In our case it plays an alarm sound in the background, then sends a desktop notification which includes a title of whom the message is from, the entire tell line, including timestamp, as the body, and uses the EQ icon. On my machine, that looks like this:

2022-04-06-16:52:13-screenshot.png

As evidenced by the additional line sending the same message body to my telegram account, you can pretty much do whatever you want in here.

Bonus Round​

Since this is all done on the command line (with the exception of the desktop notification in the alert script) this opens up more advanced techniques. For example, if you ssh into your home machine from work while you have the EverQuest client running, you can see every in-game message from the comfort of your office cubicle. And if you are particularly handy with Linux, you can even get local notifications for a remotely running EQ client. The sky's the limit (but we'll leave sending messages back as an exercise to the reader!)

I hope this is as interesting for you as it is for me!
 
Last edited:
No good:
tail -f ~/mqeq/drive_c/eq/Logs/eqlog_somepcname_someserver.txt | grcat eq.conf
Traceback (most recent call last):
  File "/usr/bin/grcat", line 200, in <module>
    ll['regexp'] = re.compile(ll['regexp']).search
  File "/usr/lib/python3.9/re.py", line 252, in compile
    return _compile(pattern, flags)
  File "/usr/lib/python3.9/re.py", line 304, in _compile
    p = sre_compile.compile(pattern, flags)
  File "/usr/lib/python3.9/sre_compile.py", line 764, in compile
    p = sre_parse.parse(p, flags)
  File "/usr/lib/python3.9/sre_parse.py", line 962, in parse
    raise source.error("unbalanced parenthesis")
re.error: unbalanced parenthesis at position 61

Something is broken on PoP!_OS using latest version 1.13 from system package manager.
 
It looks like some extra BB code formatting got pasted in there. I think I have corrected it now, please try again with the new eq.conf file.
 
Tip - Fun with Log Files (Linux)

Users who are viewing this thread

Back
Top