Highlight standard elements in log4* like log-files.
authorOleksandr Gavenko <gavenkoa@gmail.com>
Wed, 09 Oct 2013 18:05:14 +0300
changeset 1076 eed45b8a9e3a
parent 1075 df229243950a
child 1077 1fd5c6a97073
Highlight standard elements in log4* like log-files.
.emacs-my
log4-hi-mode.el
--- a/.emacs-my	Wed Oct 09 16:44:42 2013 +0300
+++ b/.emacs-my	Wed Oct 09 18:05:14 2013 +0300
@@ -1070,6 +1070,7 @@
   (when (string-match "/var/log/\\|\\.log\\'"
                       (buffer-file-name (current-buffer)))
     (auto-revert-tail-mode 1)
+    (log4-hi-mode 1)
     ))
 (add-hook 'find-file-hook 'my-auto-revert-tail-mode-hook)
 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/log4-hi-mode.el	Wed Oct 09 18:05:14 2013 +0300
@@ -0,0 +1,23 @@
+
+(require 'compile)
+
+(defvar log4-hi-keywords
+  '(("FATAL\\|ERROR" . compilation-error-face)
+    ("WARN" . compilation-warning-face)
+    ("INFO\\|DEBUG\\|TRACE" . compilation-info-face) ))
+
+;;;###autoload
+(define-minor-mode log4-hi-mode
+  "Highlight standard elements in log4* like log-files."
+  nil " log4-hi" nil
+  :global nil
+  (message "%s" log4-hi-mode)
+  (catch 'exit
+    (when log4-hi-mode
+      (font-lock-mode 1)
+      (font-lock-add-keywords nil log4-hi-keywords)
+      (throw 'exit nil))
+    (font-lock-remove-keywords nil log4-hi-keywords))
+  (font-lock-fontify-buffer))
+
+(provide 'log4-hi-mode)