With the most recent updates to mIRC, I've noticed that you can now search logs for specific strings. However, this let me down by only giving you the file names, rather than the actual lines where the strings are.
With LogSearch, you can search through your logs for specific strings, and have all matching lines returned in an interface. You may also select specific logfiles to search through, or narrow your search to certain networks. You can also export the results to a .txt file (which will be stored as logsearch_TEMP.txt in the folder where your mirc.exe is), or search specific files.
WARNING: Searching for items such as "Hello" may yield tens of thousands of results, and may take a little bit. However v2.0 switched to using filter, which is much, MUCH quicker than the old method, so it shouldn't be so bad. (6 minutes for 1279 hits in the old way, about 5 seconds in v2.0)
I've also added full instructions in the snippet, since I realized some features were definitely not obvious (such as clipboarding). If you are concerned with file size, feel free to trim the instructions out.
Updates with 3.0:
*After reading one of the fine tutorials in the forums, and doing some testing, using an @Window for buffering the /filter turned out to give a massive performance boost to this project. I have incorporated @-Buffering to help speed up the search. The most noticeable performance increase is while performing a Refined Search.
*Also, when I had updated to 2.4 I never changed the version number in the script. Fixed, now at 3.0
/*
LogSearch v3.0 (03/28/11)
By Illogic
With credit to WorldDMT and jaytea for code optimization, and Cheiron for
ideas.
To Use:
1.) Type /logsearch in any mIRC window to bring up the interface.
2.) Enter a search string into the search bar at the top.
3.) If you want to search ALL logfiles, just click Search. Search all files is
automatically selected on startup. Also, status window logs are omitted by
default, but you can search through them as well by unchecking the "Omit Status
Window Logs" checkbox. To search ALL files within a certain network, use the
combo select beneath the "Omit Status Window Logs" checkbox to select a network.
NOTE: To use Network Select, you MUST have "Include Network" enabled in mIRC's
Logging Options.
4.) If you want to pick through select files, select the Search... radio button
and double click any files you would like to search. They will be added to
the list at the bottom. If you want to remove files from the Search Selected...
list, just double-click them in the bottom list. When done, click Search. If
you would like to further refine your results once your search is complete, use
the editbox under "Narrow your search."
5.) When the search is complete, you can save the results. It will save as
logsearch_results.txt in the folder where your mIRC.exe is. It is up to you to
change the name before saving another search! If you would like to clipboard a
single line from your results, just double-click the line and paste it wherever
you please.
NOTE FROM OLD VERSION: logsearch_TEMP.txt is now used as a temporary buffer for
results. logsearch_results.txt is now the file where results are saved at your
discretion.
*/
alias logsearch {
dialog -m log_search log_search
}
dialog log_search {
title "Log Search"
size -1 -1 337 194
option dbu
box "Search for...", 1, 2 3 246 21
edit "", 2, 5 11 200 10, autohs
button "Search!", 3, 207 10 37 11
list 4, 2 46 246 132, size extsel hsbar vsbar
button "Save Results", 5, 3 180 45 12
button "Close", 6, 290 180 45 12, ok
box "Search In...", 7, 250 3 85 174
radio "Search All Files", 8, 253 11 50 10, group
radio "Search...", 9, 253 20 50 10
list 10, 253 52 78 70, sort size vsbar
list 11, 253 124 78 48, sort size vsbar
check "Omit Status Window Logs", 12, 254 29 73 10
combo 13, 253 39 78 50, size drop
edit "", 14, 99 181 140 10, read center
box "Narrow your search...", 15, 2 25 246 20
edit "", 16, 5 33 240 10, autohs
}
on *:dialog:log_search:*:*: {
if ($devent = init) {
window -h @LSFilter
var %x 0
var %y $findfile($logdir,*.log,0)
noop $findfile($logdir,*.log,0,did -a $dname 10 $nopath($1-))
filter -ciox $dname 10 $dname 10 status.*
did -c $dname 8,12
did -a $dname 13 $chr(42)
var %x 0
var %y $did($dname,10).lines
var %tok
while (%x < %y) {
inc %x
var %t $did($dname,10,%x).text
var %u $numtok(%t,46)
if (%u < 4) continue
var %fin $gettok(%t,$calc(%u - 2),46)
if (!$istok(%tok,%fin,46)) did -a $dname 13 %fin
var %tok $addtok(%tok,%fin,46)
}
did -c $dname 13 1
did -a $dname 14 LogSearch 3.0, by IllogicTC
set %logsearch.edit 0
}
if ($devent = close) {
window -c @LSFilter
unset %ls_total_*
}
if ($devent = edit) && ($did = 16) {
if ($len($did($dname,16)) > %logsearch.edit) && ($len($did($dname,16)) > 0) {
filter -ciw $dname 4 @LSFilter $+($chr(42),$did($dname,16),$chr(42))
filter -cwo @LSFilter $dname 4 *
inc %logsearch.edit
did -ra $dname 14 Refined Search: $did($dname,4).lines found.
}
elseif ($len($did($dname,16)) < %logsearch.edit) && ($len($did($dname,16)) > 0) {
did -r $dname 4
filter -cfw $lstempdir @LSFilter $+($chr(42),$did($dname,16),$chr(42))
filter -cwo @LSFilter $dname 4 *
dec %logsearch.edit
did -ra $dname 14 Refined Search: $did($dname,4).lines found.
}
elseif ($len($did($dname,16)) = 0) {
filter -cfw $lstempdir @LSFilter *
filter -cwo @LSFilter $dname 4 *
did -ra $dname 14 %ls_total_finds in %ls_total_files files.
}
}
if ($devent = dclick) {
if ($did = 10) did -a $dname 11 $did($dname,10).seltext
if ($did = 11) did -d $dname 11 $did($dname,11).sel
if ($did = 4) clipboard $did($dname,4).seltext
}
if ($devent = sclick) {
if ($did == 13) {
did -r $dname 10
if ($did($dname,13).sel != 1) {
var %x $+($chr(42),.,$did($dname,13).seltext,.,$chr(42),.,log)
noop $findfile($logdir,%x,0,did -a $dname 10 $nopath($1-))
}
if ($did($dname,12).state = 1) filter -ciox $dname 10 $dname 10 status.*
else noop $findfile($logdir,*.log,0,did -a $dname 10 $nopath($1-))
}
if ($did = 12) {
if ($did($dname,12).state = 1) {
did -r $dname 10
if ($did($dname,13).sel = 1) noop $findfile($logdir,*.log,0,did -a $dname 10 $nopath($1-))
else {
var %x $+($chr(42),.,$did($dname,13).seltext,.,$chr(42),.,log)
noop $findfile($logdir,%x,0,did -a $dname 10 $nopath($1-))
}
filter -ciox $dname 10 $dname 10 status.*
}
else {
did -r $dname 10
if ($did($dname,13).sel = 1) noop $findfile($logdir,*.log,0,did -a $dname 10 $nopath($1-))
else {
var %x $+($chr(42),.,$did($dname,13).seltext,.,$chr(42),.,log)
noop $findfile($logdir,%x,0,did -a $dname 10 $nopath($1-))
}
}
}
if ($did = 3) {
did -ra $dname 14 Beginning Search...
did -r $dname 4,16
var %string $did($dname,2)
if ($did($dname,8).state = 1) {
write -c $lstempdir
clear @LSFilter
var %tot 0
var %x 0
var %y $did($dname,10).lines
while (%x < %y) {
inc %x
var %dir $+($logdir,$did($dname,10,%x).text)
aline @LSFilter $+($chr(60),$chr(60),$nopath(%dir),$chr(62),$chr(62))
filter -fw %dir @LSFilter %string
inc %tot $filtered
did -ra $dname 14 Files Searched: %x of %y $+ $chr(44) %tot found...
}
aline @LSFilter Total Matches: %tot in %y files.
filter -wo @LSFilter $dname 4 *
filter -wf @LSFilter $lstempdir *
write $lstempdir Total Matches: %tot in %y files.
did -ra $dname 14 COMPLETE! %tot in %y files.
set %ls_total_finds %tot
set %ls_total_files %y
}
if ($did($dname,9).state = 1) {
write -c $lstempdir
clear @LSFilter
var %tot 0
var %x 0
var %y $did($dname,11).lines
while (%x < %y) {
inc %x
var %dir_temp $did($dname,11,%x)
var %dir $+($logdir,%dir_temp)
aline @LSFilter $+($chr(60),$chr(60),%dir_temp,$chr(62),$chr(62))
filter -fw %dir @LSFilter %string
inc %tot $filtered
did -ra $dname 14 Files Searched: %x of %y $+ $chr(44) %tot found...
}
aline @LSFilter Total Matches: %tot in %y files.
filter -wo @LSFilter $dname 4 *
filter -wf @LSFilter $lstempdir *
write $lstempdir Total Matches: %tot in %y files.
did -ra $dname 14 COMPLETE! %tot in %y files.
set %ls_total_finds %tot
set %ls_total_files %y
}
}
if ($did = 5) {
write -c $lsdirect
filter -if $dname 4 $lsdirect *
}
}
}
alias -l lsdirect { return $+($deltok($mircexe,$numtok($mircexe,92),92),$chr(92),logsearch_results.txt) }
alias -l lstempdir { return $+($deltok($mircexe,$numtok($mircexe,92),92),$chr(92),logsearch_TEMP.txt) }
I could do a quick-fix where it could do that, but you would have to have "Include Network" enabled under logging. I will also look into a proper fix.
**UPDATE: I did the quick-fix. As stated above, with "Include Network" enabled, you can use the new combo-box to select a specific network name, or leave it on the asterisk if you REALLLLYYY want to look through all of them.
i have spotted an area this could be upgraded. atm it searches every net that the mirc has been on for keywords and with me being on 7 nets it is trashing my mirc atm doing searches with the not responding message etc etc..
with mirc's log section you can select the network to look under
this might be something to look at for this script so you can select what network to look at based on what nets it is connected to via a drop down menu.
sure, these are all identifiers with 'side effects' (there are even a few more); they affect the scripting environment in more ways than just by returning a value. it can be sensible to use /noop even when you're not dealing with identifiers that have potential side effects. for example, i use it in my /benchmark snippet to help test how long it takes to evaluate an arbitrary line of code.
anywhere you wish to evaluate an identifier and discard its return value. you typically see it with $findfile(), $read() (to grab $readn), $regsub(), $com(), $fread() (to advance the pointer) and the group of identifiers that create/modify binary variables such as certain usages of $hget(), $compress(), $encode/$decode, etc.
Ah, okay. Quite interesting, I never realized what noop did, since the description was quite ambiguous with no examples given. Thanks! Basically in certain situations, it acts as a faster and much more efficient while loop? And also, my problem with $findfile() was for some stupid reason I was only entering $dname 10, instead of the whole command =\
for an explanation of why $findfile() used in that way is inefficient, take a look at my post on: http://www.hawkee.com/snippet/7948/
much more optimal is to take advantage of $findfile()'s command or window parameters:
if $devent == init {
noop $findfile($logdir, *.log, 0, did -a $dname 10 $nopath($1-))
; etc.
u can use $nopath into your init
on *:dialog:log_search:*:*:{
if $devent == init {
var %x 0
while $findfile($logdir,*.log,%x) {
inc %x
did -a $dname 10 $nopath($findfile($logdir,*.log,%x))
}
did -c $dname 8
}
u can remove if ($did == 6) dialog -x $dname and add "OK" in the parameter of button
button "Close", 6, 290 180 45 12, ok
$did($dname,N).text can be $did(N)