@@ -458,6 +458,16 @@ Standard is, 0 (error), 1 (warning), 2 (info), 3 (log), 4 or above (debug)."
458458 :type 'boolean
459459 :group 'eask )
460460
461+ (defcustom eask-level-color
462+ '((debug . ansi-blue)
463+ (log . ansi-white)
464+ (info . ansi-cyan)
465+ (warn . ansi-yellow)
466+ (error . ansi-red))
467+ " Alist of each log level's color, in (SYMBOL . ANSI-FUNCTION)."
468+ :type 'alist
469+ :group 'eask )
470+
461471(defun eask--verb2lvl (symbol )
462472 " Convert verbosity SYMBOL to level."
463473 (cl-case symbol
@@ -493,15 +503,12 @@ and the BODY will be executed silently."
493503(defun eask-warn (msg &rest args ) (apply #'eask--msg 'warn " [WARNING]" msg args))
494504(defun eask-error (msg &rest args ) (apply #'eask--msg 'error " [ERROR]" msg args))
495505
496- (defmacro eask-log-2 (msg &rest args )
497- " "
498- (declare (indent 2 ) (debug t ))
499- `(eask--msg 'log " [LOG]" (eask-with-ansi ,msg ,@args )))
500-
501- (defun eask--msg (level prefix msg &rest args )
506+ (defun eask--msg (symbol prefix msg &rest args )
502507 " If LEVEL is at or below `eask-verbosity' , log message."
503- (eask-with-verbosity level
504- (message " %s " (apply #'eask--format prefix msg args))))
508+ (eask-with-verbosity symbol
509+ (let* ((ansi-function (cdr (assq symbol eask-level-color)))
510+ (output (funcall ansi-function (apply #'eask--format prefix msg args))))
511+ (message " %s " output))))
505512
506513(defun eask--format (prefix fmt &rest args )
507514 " Format Eask messages."
@@ -511,15 +518,6 @@ and the BODY will be executed silently."
511518 fmt)
512519 args))
513520
514- (defmacro eask-with-ansi (fmt &rest args )
515- " Simply wrapper for macro `with-ansi' ."
516- `(with-ansi (format ,fmt ,@args )))
517-
518- (defmacro eask-message (fmt &rest args )
519- " Like function `message' but with color."
520- (declare (indent 2 ) (debug t ))
521- `(message (concat (eask-with-ansi ,fmt ,@args ) " \n " )))
522-
523521; ;
524522; ;; File
525523
0 commit comments