ctrl+shift+p filters: :st2 :st3 :win :osx :linux
Browse

Log​Magic

by syko ST2/ST3

Javascript console.log statements at the tip of your fingers

Details

  • 1.3.0
  • github.​com
  • github.​com
  • 11 months ago
  • 27 minutes ago
  • 2 years ago

Installs

  • Total 819
  • Win 370
  • OS X 328
  • Linux 121
Apr 20 Apr 19 Apr 18 Apr 17 Apr 16 Apr 15 Apr 14 Apr 13 Apr 12 Apr 11 Apr 10 Apr 9 Apr 8 Apr 7 Apr 6 Apr 5 Apr 4 Apr 3 Apr 2 Apr 1 Mar 31 Mar 30 Mar 29 Mar 28 Mar 27 Mar 26 Mar 25 Mar 24 Mar 23 Mar 22 Mar 21 Mar 20 Mar 19 Mar 18 Mar 17 Mar 16 Mar 15 Mar 14 Mar 13 Mar 12 Mar 11 Mar 10 Mar 9 Mar 8 Mar 7
Windows 0 1 1 0 0 0 0 0 0 0 1 0 1 0 0 1 1 0 1 0 0 0 1 1 0 1 0 0 0 0 0 0 1 0 0 0 0 1 0 0 0 1 0 0 0
OS X 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 3 0 1 1 1 0
Linux 1 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0

Readme

Source
raw.​githubusercontent.​com

SublimeLogMagic

Easily log JavaScript variables and parameters with keyboard shortcuts.

Now with CoffeeScript support!

Installing

Simply look for “Log Magic” in Package Control.

Usage

Simply press cmd+alt+j (ctrl+alt+j) to produce magic downwards or cmd+alt+k (ctrl+alt+k) to produce magic upwards. When you're done press cmd+alt+l (ctrl+alt+l) to remove all magic.

You can also run these commands manually: - LogMagic Statement (down) - LogMagic Statement (up) - LogMagic Remove all

Features

Log quickly

Any log statement is just a keyboard shortuct away

Log anything quickly

Log anything

LogMagic inspects the current line and tries to extract interesting information from it: - variable assignments - function parameters in a function definition - parameters in a function call - supports ES6 destructuring - supports ES6 optional parameters - supports flowtype (to some extent) - ignores known values such as numbers, true, false, null and undefined - falls back to printing L<line number> if it fails to parse anything meaningful

Cycle through log types

Press the same keyboard shortcuts when already on a log statement to cycle through log, info, warn and error.

Log cycle

Up / Down support

You can add the log statement on the previous or the next line. This is especially helpful in case of return statements.

Log upwards

Logging upwards can also change what's logged. Eg in the following case we're more interested in the arguments passed to the callback than the variable assignment.

Log upwards smartly

ES6 destructuring support

LogMagic can parse destructuring and extract the necessary variable names from it (even in case of renamed properties)

Log ES6 destructuring

Flowtype support

Flowtype is cool. Best effort has been made to ignore flowtype's annotations and still produce a meaningful log statement (but expect kinks and bugs here).

Log with Flowtype

Remove all log statements

With one command you can remove all log statements from the current file.

Remove all log statements

CoffeeScript support

Logs stuff from coffeescript code. Even tries to understand function calls without parenthesis. Support for this is limited but 90% of the time it should work all the time.

Customizing

There are no customizable settings (feel free to make an issue).

You can override the custom keyboard shortcuts by adding this to your personal keyboard shortcuts file:

[
    { "keys": ["super+alt+j"], "command": "log_magic_down", "context":
        [
            { "operand": "source.js", "operator": "equal", "match_all": true, "key": "selector" }
        ]
    },
    { "keys": ["super+alt+k"], "command": "log_magic_up", "context":
        [
            { "operand": "source.js", "operator": "equal", "match_all": true, "key": "selector" }
        ]
    },
    { "keys": ["super+alt+l"], "command": "log_magic_remove_all", "context":
        [
            { "operand": "source.js", "operator": "equal", "match_all": true, "key": "selector" }
        ]
    },
    { "keys": ["super+alt+j"], "command": "log_magic_down", "context":
        [
            { "operand": "source.coffee", "operator": "equal", "match_all": true, "key": "selector" }
        ]
    },
    { "keys": ["super+alt+k"], "command": "log_magic_up", "context":
        [
            { "operand": "source.coffee", "operator": "equal", "match_all": true, "key": "selector" }
        ]
    },
    { "keys": ["super+alt+l"], "command": "log_magic_remove_all", "context":
        [
            { "operand": "source.coffee", "operator": "equal", "match_all": true, "key": "selector" }
        ]
    }
]

Contributing

Issues are welcome, especially if it spits out invalid javascript.

Btw this plugin should theoretically mostly work for most C-based languages (although by default the keyboard shortcuts are only enabled for JavaScript and it spits out console.* statements).