Enable adoc-mode for .adoc files.
;;; log4-hi-mode.el --- Syntax highlighting logs keywords.
;;; Commentary:
;; Used for highlighting ERROR/WARN/INFO like keywords and dates in logs.
;;; Code:
(defgroup log4-hi nil
"`log4-hi-mode' mode for highlighting logs."
:prefix "log4-hi-"
:group 'text)
(defface log4-hi-error-face
'((t :inherit error))
"Face for critical message."
:group 'log4-hi)
(defface log4-hi-warn-face
'((t :inherit warning))
"Face for urgent message."
:group 'log4-hi)
(defface log4-hi-info-face
'((t :inherit success))
"Face for informational message."
:group 'log4-hi)
(defface log4-hi-func-face
'((t :inherit font-lock-function-name-face))
"Face for functions in trace."
:group 'log4-hi)
(defface log4-hi-time-face
'((t :inherit font-lock-builtin-face))
"Face for time."
:group 'log4-hi)
(defvar log4-hi-keywords
'(("FATAL\\|ERROR" . 'log4-hi-error-face)
("WARN\\|SEVERE" . 'log4-hi-warn-face)
("INFO\\|DEBUG\\|TRACE" . 'log4-hi-info-face) ))
(defvar log4-hi-func-keywords
'(("at [[:alnum:].]+\\.\\([[:alnum:]$]+\\.[[:alnum:]$<>]+\\)([[:alnum:]]+\\.java:[0-9]+)" 1 'log4-hi-func-face) ))
(defvar log4-hi-time-keywords
'(("\\(:?[0-9]\\{2\\}?[0-9]\\{2\\}.[0-9]\\{2\\}.[0-9]\\{2\\}.\\|\\<\\)[0-9]?[0-9]:[0-9][0-9]:[0-9][0-9]\\>\\(:?\\.[0-9]\\{3\\}\\)?" . 'log4-hi-time-face)))
(defvar log4-hi-func t
"Mark to use hilighting of function names in stacktraces. Currently only Java supported.")
(defvar log4-hi-mode-map (make-sparse-keymap)
"Keymap for `log4-hi-mode'.")
;;;###autoload
(define-minor-mode log4-hi-mode
"Highlight standard elements in log4* like log-files."
nil " log4-hi" log4-hi-mode-map
:global nil
(catch 'exit
(when log4-hi-mode
(font-lock-mode 1)
(font-lock-add-keywords nil log4-hi-keywords)
(font-lock-add-keywords nil log4-hi-time-keywords)
(when log4-hi-func (font-lock-add-keywords nil log4-hi-func-keywords))
(throw 'exit nil))
(font-lock-remove-keywords nil log4-hi-keywords)
(font-lock-remove-keywords nil log4-hi-time-keywords)
(font-lock-remove-keywords nil log4-hi-func-keywords))
(font-lock-flush))
(provide 'log4-hi-mode)
(provide 'log4-hi-mode)
;;; log4-hi-mode.el ends here