Add factilities to filter logs from different modules

WIP-cache
Hugo Thunnissen 10 months ago
parent db370623da
commit f2ece03f2a

@ -33,7 +33,9 @@
(defvar phpinspect-parse-context nil
"dummy for compilation")
(declare-function phpinspect-pctx-register-changeset "phpinspect-parse-context" (pctx changeset)))
(declare-function phpinspect-pctx-register-changeset "phpinspect-parse-context" (pctx changeset))
(phpinspect--declare-log-group 'bmap))
(cl-defstruct (phpinspect-bmap (:constructor phpinspect-make-bmap))
(starts (make-hash-table :test #'eql

@ -117,12 +117,15 @@ use."
(phpinspect-bmap-make-location-resolver (phpinspect-buffer-map buffer)))
token))))
(cl-defmethod phpinspect-buffer-root-meta ((buffer phpinspect-buffer))
(phpinspect-bmap-root-meta (phpinspect-buffer-map buffer)))
(defun phpinspect-display-buffer-tree ()
(interactive)
(when phpinspect-current-buffer
(let ((buffer phpinspect-current-buffer))
(pop-to-buffer (generate-new-buffer "phpinspect-buffer-tree"))
(insert (pp-to-string (phpinspect-buffer-tree buffer)))
(read-only-mode))))
(pop-to-buffer (generate-new-buffer "phpinspect-buffer-tree"))
(insert (pp-to-string (phpinspect-buffer-parse buffer 'no-interrupt)))
(read-only-mode))))
(provide 'phpinspect-buffer)

@ -23,6 +23,11 @@
;;; Code:
(require 'phpinspect-util)
(eval-when-compile
(phpinspect--declare-log-group 'edtrack))
(cl-defstruct (phpinspect-edtrack (:constructor phpinspect-make-edtrack))
(edits nil
:type list)

@ -30,6 +30,59 @@ PHP. Used to optimize string comparison.")
(defvar phpinspect--debug nil
"Enable debug logs for phpinspect by setting this variable to true")
(defun phpinspect-toggle-logging ()
(interactive)
(if (setq phpinspect--debug (not phpinspect--debug))
(message "Enabled phpinspect logging.")
(message "Disabled phpinspect logging.")))
(defvar phpinspect-log-groups nil)
(defvar phpinspect-enabled-log-groups nil)
(defvar-local phpinspect--current-log-group nil)
(define-inline phpinspect--declare-log-group (group)
(unless (and (inline-const-p group) (symbolp (inline-const-val group)))
(inline-error "Log group name should be a symbol"))
(inline-quote
(progn
(add-to-list 'phpinspect-log-groups (cons (or load-file-name buffer-file-name) ,group) nil #'equal))))
(defun phpinspect-log-group-enabled-p (group)
(seq-find (lambda (cons)
(eq group (cdr cons)))
phpinspect-enabled-log-groups))
(phpinspect--declare-log-group 'bam)
(define-inline phpinspect--log (&rest args)
(let ((log-group (alist-get (or load-file-name buffer-file-name) phpinspect-log-groups nil nil #'string=)))
(push 'list args)
(inline-quote
(when (and phpinspect--debug
(or (not phpinspect-enabled-log-groups)
,(when log-group
(inline-quote
(member (quote ,log-group) phpinspect-enabled-log-groups)))))
(with-current-buffer (get-buffer-create "**phpinspect-logs**")
(unless window-point-insertion-type
(set (make-local-variable 'window-point-insertion-type) t))
(goto-char (buffer-end 1))
(insert (concat "[" (format-time-string "%H:%M:%S") "]: "
,(if log-group (concat "(" (symbol-name log-group) ") ") "")
(apply #'format ,args) "\n")))))))
(defun phpinspect-filter-logs (group-name)
(interactive (list (completing-read "Log group: "
(mapcar (lambda (g) (symbol-name (cdr g)))
phpinspect-log-groups) nil t)))
(add-to-list 'phpinspect-enabled-log-groups (intern group-name)))
(defun phpinspect-unfilter-logs ()
(interactive)
(setq phpinspect-enabled-log-groups nil))
(defsubst phpinspect-intern-name (name)
(intern name phpinspect-name-obarray))
@ -46,21 +99,6 @@ PHP. Used to optimize string comparison.")
(push item new-plist))
(nreverse new-plist)))
(defun phpinspect-toggle-logging ()
(interactive)
(if (setq phpinspect--debug (not phpinspect--debug))
(message "Enabled phpinspect logging.")
(message "Disabled phpinspect logging.")))
(defsubst phpinspect--log (&rest args)
(when phpinspect--debug
(with-current-buffer (get-buffer-create "**phpinspect-logs**")
(unless window-point-insertion-type
(set (make-local-variable 'window-point-insertion-type) t))
(goto-char (buffer-end 1))
(insert (concat "[" (format-time-string "%H:%M:%S") "]: "
(apply #'format args) "\n")))))
(cl-defstruct (phpinspect--pattern
(:constructor phpinspect--make-pattern-generated))
"An object that can be used to match lists to a given

Loading…
Cancel
Save