log4-hi-mode.el
author Oleksandr Gavenko <gavenkoa@gmail.com>
Tue, 11 Mar 2014 00:05:41 +0200
changeset 1125 2fab89e9858e
parent 1083 d4b063fc0f5e
child 1134 d91fa7f7033a
permissions -rw-r--r--
Fix: Symbol's function definition is void: global-semantic-idle-scheduler-mode


(defface log4-hi-error-face
  '((t :inherit error))
  "Face for critical message.")

(defface log4-hi-warn-face
  '((t :inherit warning))
  "Face for urgent message.")

(defface log4-hi-info-face
  '((t :inherit success))
  "Face for informational message.")

(defface log4-hi-func-face
  '((t :inherit font-lock-function-name-face))
  "Face for functions in trace.")

(defvar log4-hi-keywords
  '(("FATAL\\|ERROR" . 'log4-hi-error-face)
    ("WARN" . 'log4-hi-warn-face)
    ("INFO\\|DEBUG\\|TRACE" . 'log4-hi-info-face) ))

(defvar log4-func-hi-keywords
  '(("at [[:alnum:].]+\\.\\([[:alnum:]$]+\\.[[:alnum:]$<>]+\\)([[:alnum:]]+\\.java:[0-9]+)" 1 'log4-hi-func-face) ))

(defvar log4-func-hi t
  "Mark to use hilighting of function names in stacktraces. Currently only Java supported.")

;;;###autoload
(define-minor-mode log4-hi-mode
  "Highlight standard elements in log4* like log-files."
  nil " log4-hi" nil
  :global nil
  (catch 'exit
    (when log4-hi-mode
      (font-lock-mode 1)
      (font-lock-add-keywords nil log4-hi-keywords)
      (when log4-func-hi (font-lock-add-keywords nil log4-func-hi-keywords))
      (throw 'exit nil))
    (font-lock-remove-keywords nil log4-hi-keywords)
    (font-lock-remove-keywords nil log4-func-hi-keywords))
  (font-lock-fontify-buffer))

(provide 'log4-hi-mode)