[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Log file helper

A few weeks ago we discussed the issue of efficiently
reading log files inside emacspeak, and I had pointed to
forms mode.

Here is a slightly cleaned up version of what I use to
quickly examine /var/adm/messages on linux and solaris 

Instructions on use:

Save the attached file 
as messages.el  and open it with
M-x forms-find-file

When prompted specify the log file you want to view
--/var/adm/messages is the default.

You will also be prompted for a filter pattern --if you
specify a string, lines matching that string will be nuked
the log is displayed.

Finally, you can filter out other unwanted lines by invoking 
M-x forms-rerun-filter 
and specifying a pattern.

You should of course read the help on forms mode to learn
how to use all its facilities.

Note that the attached file splits records as they appear in
--you can modify it appropriately for other log formats.
;;;$Id: messages.el,v 1.2 1998/12/19 02:35:55 raman Exp $
;;; Display /var/adm/messages
(setq forms-read-only t)
(setq forms-file
      (read-file-name  "Messages file: "
(defun flush-unwanted-messages ()
  "Prompt for pattern and flush matching lines"
  (let ((pattern (read-from-minibuffer
                  "Specify filter pattern")))
    (when (> (length pattern) 0)

(setq forms-read-file-filter 'flush-unwanted-messages)
(setq forms-read-only nil)
(setq forms-field-sep
      (substring (system-name)
(string-match "\\." (system-name))))
(setq forms-number-of-fields 2)

(setq forms-format-list

(defun forms-rerun-filter ()
  "Rerun  filter --allows us to nuke more matching records"
  (declare (special forms--file-buffer))
    (set-buffer forms--file-buffer)
    (let ((inhibit-read-only t)
          (file-modified (buffer-modified-p)))
      (if (not file-modified) (set-buffer-modified-p
  (let (ro)
    (setq forms--total-records
		  ;;(message "forms: counting records...")
		  (set-buffer forms--file-buffer)
		  (bury-buffer (current-buffer))
		  (setq ro buffer-read-only)
		  (count-lines (point-min) (point-max)))
	      ;;(message "forms: counting records... done.")
    (if ro
	(setq forms-read-only t)))
  (message "%s records after filtering"

Emacspeak Files | Subscribe | Unsubscribe