Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/artawower/turbo-log

Fast log message inserting for quick debug.
https://github.com/artawower/turbo-log

emacs emacs-lisp logger turbo-console-log

Last synced: 7 days ago
JSON representation

Fast log message inserting for quick debug.

Awesome Lists containing this project

README

        

:PROPERTIES:
:ID: turbo-log-readme
:END:

#+html:


#+html:
#+html:

#+html:

#+html:
#+html: Buy Me A Coffee donate button
#+html:

#+html:
#+html: Patreon donate button
#+html:

#+html: wakatime
#+html: CI
#+html:

* Turbo log - fast logging selected line or region
This project inspired by a similar package for [[https://marketplace.visualstudio.com/items?itemName=ChakrounAnas.turbo-console-log][vs-code - turbo-console-log]], and provides functionality for fast log message inserting under current line.
It works for *js-mode, typescript-mode, go-mode and python*.
** How it works?
[[./images/sample.gif]]
** Installation
*** quelpa
#+BEGIN_SRC emacs-lisp
(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-treesit-p t))
#+END_SRC
*** doom
#+BEGIN_SRC emacs-lisp
;; 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-treesit-p t))
#+END_SRC
*** Cloning the repo
Clone the repo to a directory, say =./emacs.d/lisp= with
#+BEGIN_SRC shell
git clone https://github.com/chookity-pokk/turbo-log.git
#+END_SRC

Then put this in your init to load the package
#+BEGIN_SRC elisp
(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-treesit-p t))
#+END_SRC

*** For emacs version < 29
emacs versions below 29 are no longer supported, but you can still use an older version:
#+BEGIN_SRC emacs-lisp :results silent
(use-package turbo-log
:defer t
:ensure (turbo-log :type git :host github :repo "Artawower/turbo-log.el" :branch "tree-sitter"))
#+END_SRC
** 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-treesit-p= - allow to insert logs without treesit (in such case logger will be inserted next line only, also its a necessary for modes without treesit support)
#+END_SRC
*** 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:

#+BEGIN_SRC emacs-lisp
(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'")
#+END_SRC

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
+ [X] Python
+ [X] Golang
+ [X] Javascript
+ [X] Typescript
+ [X] Java
+ [X] C#
+ [X] Rust
+ [X] Ruby
+ [-] Lua (Without treesit)
+ [-] Elisp (Without treesit)
+ [ ] C++

** 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

#+BEGIN_SRC bash
eldev prepare && eldev -p -dtT -C test
#+END_SRC