[[https://github.com/Artawower/turbo-log/actions][https://github.com/artawower/turbo-log/actions/workflows/lint.yml/badge.svg]] [[https://wakatime.com/badge/github/Artawower/turbo-log.svg]]
(use-package tree-sitter-langs :ensure t :defer t)
(use-package tree-sitter :ensure t :after tree-sitter-langs)
** Installation *** quelpa
(use-packa) (use-package turbo-log :quelpa (turbo-log :fetcher github :repo "artawower/turbo-log.el") :bind (("C-s-l" . turbo-log-print) ("C-s-i" . turbo-log-print-immediately) ("C-s-h" . turbo-log-comment-all-logs) ("C-s-s" . turbo-log-uncomment-all-logs) ("C-s-[" . turbo-log-paste-as-logger) ("C-s-]" . turbo-log-paste-as-logger-immediately) ("C-s-d" . turbo-log-delete-all-logs)) :config (setq turbo-log-msg-format-template "\"🚀: %s\"") (setq turbo-log-allow-insert-without-tree-sitter-p t))
*** doom
;; packages.el (package! turbo-log :recipe (:host github :repo "artawower/turbo-log")) ;; config.el (use-package turbo-log :bind (("C-s-l" . turbo-log-print) ("C-s-i" . turbo-log-print-immediately) ("C-s-h" . turbo-log-comment-all-logs) ("C-s-s" . turbo-log-uncomment-all-logs) ("C-s-[" . turbo-log-paste-as-logger) ("C-s-]" . turbo-log-paste-as-logger-immediately) ("C-s-x" . turbo-log-delete-all-logs)) :config (setq turbo-log-msg-format-template "\"🚀: %s\"") (setq turbo-log-allow-insert-without-tree-sitter-p t))
*** Cloning the repo Clone the repo to a directory, say =./emacs.d/lisp= with
git clone https://github.com/chookity-pokk/turbo-log.git
Then put this in your init to load the package
(add-to-list 'load-path "~/.emacs.d/lisp/turbo-log") (require 'turbo-log) (use-package turbo-log :bind (("C-s-l" . turbo-log-print) ("C-s-i" . turbo-log-print-immediately) ("C-s-h" . turbo-log-comment-all-logs) ("C-s-s" . turbo-log-uncomment-all-logs) ("C-s-[" . turbo-log-paste-as-logger) ("C-s-]" . turbo-log-paste-as-logger-immediately) ("C-s-d" . turbo-log-delete-all-logs)) :config (setq turbo-log-msg-format-template "\"🚀: %s\"") (setq turbo-log-allow-insert-without-tree-sitter-p t))
** Customization *** Common configs =turbo-log-msg-format-template= - template for entire part inside logger
=turbo-log-payload-format-template= - template for payload part (selected region or implicite extracted identifier)
=turbo-log-line-number-format-template= - optional template for formatting line number, when not provided, the line number will not be inserted
=turbo-log-buffer-name-format-template= - template for file name inserting
=turbo-log-argument-divider= - divider for arguments (in most case it's a comma)
=turbo-log-allow-insert-without-tree-sitter-p= - allow to insert logs without tree-sitter (in such case logger will be inserted next line only, also its a necessary for modes without tree-sitter support)
*** Language specific configs =turbo-log-loggers= - its a most interesting part of your config. You can use every settings as plist for specific logger (without =turbo-log= prefix), for example:
(turbo-log-configure :modes (typescript-mode js2-mode web-mode) :strategy merge
:loggers ("console.log(%s)" "console.debug(%s)" "console.warn(%s)") :jump-list ((class_declaration (method_definition "constructor"))) :identifier-node-types (identifier member_expression) :post-insert-hook (prettier-prettify) :msg-format-template "'🦄: %s'")
Where:
=modes= - list of modes which have to be updated
=strategy= - update strategy, =merge= will update existing plist (only first level of nested structure), =replace= will override all mode settings
=loggers= - list of available loggers, when there are more then 1 =turbo-log-print= will ask to choose logger.
=jump-list= - internal command for insert current logger to specific line number by determined node type. Its a alist that consist of cons where car is node type and cdr is a alist of inserting position and optional name of foud node type, after which logger will be inserted.
=identifier-node-types= - optional alist of node types for extracting identifiers
=post-insert-hook= - list of hooks that will be triggered after logger inserted. Its a good place to call =format-all-buffer= or =prettier-prettify= methods.
** Tested languages
** Contributing Any contribution is greatly appreciated! Run =eldev test=, =checkdoc= and =package-lint-current-buffer= (from [[https://github.com/purcell/package-lint][package-lint]] ) before creating the pull request