Coders-IRC


IRC for Coders

Log Viewer


image
menu status,channel { 
  Log Viewer: 
  .Default: $LogViewer(D)
  .Channels: $LogViewer(C) 
  .Query/PM: $LogViewer(Q) 
  .@Windows: $LogViewer(@) 
}
alias LogViewer {
  $iif(!$window(@LogViewer),window -CkSzl20 @LogViewer $mircexe)
  dline @LogViewer $+(1-,$line(@LogViewer,0,0))
  dline -l @LogViewer $+(1-,$line(@LogViewer,0,1))
  renwin @LogViewer @LogViewer $chr(160)
  if ($1 = D) { noop $qt($findfile($logdir,*.log,@LogViewer,aline -l @LogViewer $nopath($1-))) }
  if ($1 = C) { noop $qt($findfile($logdir,#*.log,@LogViewer,aline -l @LogViewer $nopath($1-))) }
  if ($1 = @) { noop $qt($findfile($logdir,@*.log,@LogViewer,aline -l @LogViewer $nopath($1-))) }
  if ($1 = Q) { 
    var %t 1
    while (%t <= $findfile($logdir,*.log,0)) {
      aline -l @logViewer $nopath($findfile($logdir,*.log,%t)) | inc %t
    }
    dline -l @LogViewer 1- $+ $calc($fline(@LogViewer,@*,1,1)-1)
    dline -l @LogViewer 1- $+ $fline(@LogViewer,@*,0,1)
  }
}
menu @LogViewer {
  dclick {
    if ($sline(@LogViewer,1)) { 
      renwin @LogViewer @LogViewer $& 
        - Log File: $gettok($sline(@LogViewer,1),1--3,46) $&
        - Network: $gettok($sline(@LogViewer,1),-2,46) $&
        - Size: $bytes($file($qt($findfile($logdir,$sline(@LogViewer,1),1))).size).suf
      .loadbuf -rip @LogViewer $qt($findfile($logdir, $+ $sline(@LogViewer,1) $+ *,1)) 0
    }
  }
  Delete Log: { 
    if ($input(Want to delete $sline(@LogViewer,1),uy,Log File Delete)) {  
      if ($input(Are you sure you want to delete $sline(@LogViewer,1),y,Log File Delete Confirming)) { 
        .remove -b $qt($+($logdir,$sline(@LogViewer,1)))
        noop $input(Moving $sline(@LogViewer,1) to Recycle Bin. $crlf and $crlf Updating @LogViewer to Default view.,ok2,Log File Delete Confirmation)
        $LogViewer(D)
      }
    }
  }
  Reset:
  .Display: { dline @LogViewer $+(1-,$line(@LogViewer,0,0)) | renwin @LogViewer @LogViewer $chr(160) }
  .List:
  ..Default: $LogViewer(D) | noop $input(Reseting @LogViewer to Default view.,ok2,@LogViewer Reset)
  ..Channels: $LogViewer(C) | noop $input(Reseting @LogViewer to Channel view.,ok2,@LogViewer Reset)
  ..Query/PM: $LogViewer(Q) | noop $input(Reseting @LogViewer to Query/PM view.,ok2,@LogViewer Reset)
  ..@Windows: $LogViewer(@) | noop $input(Reseting @LogViewer to @Windows view.,ok2,@LogViewer Reset) 
  Search: 
  .Display: { $LogViewerSearch($remove($$?="Search term",$chr(32)),D) }
  .List: { $LogViewerSearch($remove($$?="Search term",$chr(32)),L) }
  Stats { 
    dline @LogViewer $+(1-,$line(@LogViewer,0,0)) | renwin @LogViewer @LogViewer $chr(160)
    var %Channels $fline(@LogViewer,$chr(35) $+ *,0,1) | var %@Windows $fline(@LogViewer,$chr(64) $+ *,0,1)
    var %Others $calc($findfile($logdir,*.log,0) - $calc(%Channels + %@Windows))
    echo -a 12[!]4 There are currently 12 $+ %Channels 4Channel log files 12[!]
    echo -a 12[!]4 There are currently 12 $+ %@Windows 4@Window log files 12[!]
    echo -a 12[!]4 There are currently 12 $+ %Others 4PM/Other log files 12[!] 
    echo -a 12[!]4 There are currently 12 $+ $findfile($logdir,*.log,0) 4Total log files 12[!]
  }
}
alias -l LogViewerSearch { 
  if ($1 && $isid) {
    if ($2 = D) {
      window -znk0 @LogViewerSearch $mircexe
      filter -wwcpz @LogViewer @LogViewerSearch * $+ $1 $+ *
      renwin @LogViewerSearch @LogViewerSearch $& 
        - Log File: $gettok($sline(@LogViewer,1),1--3,46) $&
        - Network: $gettok($sline(@LogViewer,1),-2,46) $&
        - Search Term: $1
      if ($filtered < 1) { 
        noop $input(Searched: $qt($1) $crlf Results: 0,ok2,@LogViewer Search Result) 
        .timer 1 2 window -c @LogViewerSearch 
      }
    }
    if ($2 == L) { 
      filter -wwcpzlL @LogViewer @LogViewer * $+ $1 $+ *
      if ($filtered < 1) { 
        noop $input(Searched: $qt($1) $crlf Results: 0 $crlf and $crlf Updating @LogViewer to Default view.,ok2,@LogViewer Search Result) 
        $LogViewer(D)
      }
    }
  }
}

Comments 1

avatar

Chain (Posted Friday, 27 August 2021)

Added ability to sort side list by default , channels only, Query/PM only or @Windows only. The reset feature allows you to reset to any of the mention options.