Coder Social home page Coder Social logo

consolewrap's Introduction

Console Wrap

Release version Stability: Stable Package Control License: MIT

This plugin helps you easily create (comment, remove, show all) log statements (console.log, print etc.)

It places selected variable in log statement like console.log("variable", variable);

This is not a snippet.

Supported languages

  • Javascript
  • Python
  • Php
  • Go

Usage

First you need to select a variable (or put cursor on it) and press "ctrl+shift+q". The log line will appear on the next line. Press "ctrl+shift+q" again to change wrapping (info,warn etc.)

You can Also remove, comment or remove commented log statements from your selsection or from all document you can find that functionality in context menu (right click) or Command Palette (command+shift+p on OS X, control+shift+p on Linux/Windows).

Screenshots

Javascript
Javascript
Python
Python
Php
Php
All Logs
All Logs

Key Binding

The default key binding is "ctrl+shift+q" and "ctrl+shift+alt+q" (insert before selection).

{ 
    "keys": ["ctrl+shift+q"], 
    "command": "console_wrap",
    "args": {"insert_before": false}
},
{ 
    "keys": ["ctrl+shift+alt+q"], 
    "command": "console_wrap",
    "args": {"insert_before": true}
}

Commands

{
    "caption": "Console Wrap: Create logs",
    "command": "console_wrap"
}, {
    "caption": "Console Wrap: Remove logs",
    "command": "console_action",
    "args": {"action": "remove"}
}, {
    "caption": "Console Wrap: Remove Commented logs",
    "command": "console_action",
    "args": {"action": "remove_commented"}
}, {
    "caption": "Console Wrap: Comment logs",
    "command": "console_action",
    "args": {"action": "comment"}
}, {
    "caption": "Console Wrap: Show all logs",
    "command": "console_action",
    "args": {"action": "show_quick_nav"}
}

Settings

{
    "js": {
        "consoleStr"   : "{title}, {variable}", // "{title}, tmpVal = {variable}" to assigne value to temporary parameter output: console.log('title', tmpVal = variable);
        "consoleFunc"  : ["console", "log"],    // You can change default log statement for example ["logger", "info"] output: logger.info('title', variable);
        "single_quotes": false,                 // If true output: console.log('title', variable);
        "semicolon"    : true,                  // If false, will not add semicolon at end of line
        "log_types"    : ["log", "info", "warn", "error"]
    },
    "py": {
        "consoleStr"   : "{title}, {variable}",
        "consoleFunc"  : ["print"],
        "single_quotes": false
    },
    "php": {
        "consoleFunc"  : ["print_r"],   // var_dump or if you have custom logger ["$logger", "debug"] output: $logger->debug($variable);
        "preTag"       : true,          // Put log in pre tag like echo '<pre>'; print_r($variable); echo '</pre>';
        "dieAfterLog"  : false          // echo '<pre>'; print_r($variable); echo '</pre>'; die();
    },
    "go": {
        "consoleStr"   : "{title}, {variable}",
        "consoleFunc"  : ["fmt", "Println"],
        "single_quotes": false,
        "log_types"    : ["Print", "Printf"]
    },
    "fileTypeMap" : {                   // Maps file type to wrapper. For example "text.html.vue": "js" means use js wrapper in vue js files
        "text.html.vue"  : "js",        // php,python,js is included by dafault ("embedding.php": "php", "source.js": "js", "source.python": "py")
        "source.ts"      : "js",
        "source.tsx"     : "js",
        "source.coffee"  : "js",
        "text.html.basic": "js",
        "text.html.blade": "js",
        "text.html.twig" : "js"
    }
}

How to install

With Package Control:

  1. Run “Package Control: Install Package” command, find and install Console Wrap plugin.
  2. Restart Sublime Text editor (if required)

Manually:

  1. Clone or download git repo into your packages folder (in Sublime Text, find Browse Packages... menu item to open this folder)
  2. Restart Sublime Text editor (if required)

consolewrap's People

Contributors

arnaudrinquin avatar bfred-it avatar bijoythomas avatar luan-nico-dextra avatar unknownuser88 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

consolewrap's Issues

Multiple comment slashes for duplicate logs

ST3: Build 3126
OS: Win7

I'm not sure if this is by design or not.

If you have multiple console logs with the same thing/value being logged it adds "//" the same number count of the identical logs. This it turn affects when you "Remove commented logs" or "Remove All logs" by only removing the first one preceding the log. It does this for both JS and PHP (haven't tested Python). Otherwise everything works good.

Before "Comment All logs"

console.log("foo");
console.log("bar");
console.log(foo);
console.log(bar);
console.log(foo);
console.log("bar");
console.log("bar");

After "Comment All logs"

// // // console.log("bar");
// // console.log(foo);
// console.log(bar);
// // console.log(foo);
// // // console.log("bar");
// // // console.log("bar");

After "Remove Commented logs" & "Remove All logs

// //
//

//
// //
// //

Support Jasmine files

Hi, somehow the Jasmine plugin defines it's own scope. Is there some way for this plugin to support .spec.js files that the Jasmine plugin (or others like it) has defined within it's purview?

Selecting string part of an existing console.* line

Currently when you select a variable that is on an existing console.* line and press the shortcut buttons you expect to get the selected variable in a new console.log above the current line.

Instead it goes through the different console.log/error/info/etc. options for the current line.

Expectation is to do that only when nothing is selected on the current line. When anything is selected it should exhibit the default behavior.

New keyboard shortcut is no good on macOS

Hi!
The new shortcut super+shift+q is being overridden by macOS global shortcut (cmd+shift+q) to log out the current user. The readme still says ctrl+shift+q so I suspect this was an unintentional change?

customizable

Is it possible to make it customizable ?

So it can be one of the following options

console.log
console.debug
console.info
console.warn
console.error

Color customization

It would be even nicer if we could be able to customize console's color in JS, like this below
colors
console.log('%cERR example example example', 'background:green;color:white;', err);

console.log value assigned to temporary parameter

Hi,

Can you modify the console.log('name',name); to console.log('name',nameVal = name); like that its easy to debug for developers.

We can access the nameVal in console for calling and binding is easy.

github

regards,

@gsivaprabu

Limit plugin to javascript files

It would be great if it worked only in .js, .coffee, .es, .jsx files, since it's weird to try to console.log in ruby file for example

Console wrap for the word where cursor is pasted

I am not sure, but I am thinking that this feature was working before:
If I put cursor at the middle of the word, then press Ctrl+Alt+Q I am expecting to have the correct console.log message.

Steps to reproduce:

  • Type: let abcd = 2;
  • Select let and copy it to the clipboard;
  • Put cursor in the middle of abcd (let ab|cd = 2);
  • Press Ctrl+Alt+Q

Actual result:
New line appeared with current clipboard content:
console.log('let', let);

Expected result:
New line apperead (based on configuration):
console.log('abcd', abcd);

I think this is good

In IE9 to 6 console.log is really a problem
remove all console.log is good

I suggest add another option like comment all console log
and perhaps add an option like do it automatically after save a file

Show file path in log

Add the ability to show file path in the generated log. Maybe we could control it via settings such as:

"consoleStr": "{path} ~ {title}, {variable}"

NameError: global name 'is_log_statement' is not defined

ST3 Console

Traceback (most recent call last):
  File "D:\Progs\Sublime_Text\sublime_plugin.py", line 574, in run_
    return self.run(edit)
  File "consolewrap in D:\Progs\Sublime_Text\Data\Installed Packages\Console Wrap for js.sublime-package", line 76, in run
NameError: global name 'is_log_statement' is not defined

Indent using space

Hello, i think for a new update you can add a setting for indent spaces, when we use your plugin :)

Error parsing settings

Hello, just getting a small error. Removing the trailing comma in my settings file fixed it, but otherwise I couldn't run the plugin.

error: Error trying to parse settings: Trailing comma before closing bracket in C:\Users\...\Console Wrap\.sublime\consolewrap.sublime-settings:8:5
Traceback (most recent call last):
  File ".\sublime_plugin.py", line 362, in run_
    return self.run(edit)
  File ".\console_wrap.py", line 111, in run
  File ".\console_wrap.py", line 83, in runCommand
ValueError: zero length field name in format

all broke after update

Hello,

your package has just updated and stopped working after that.
nothing else was changed.

I select any variable, press ctrl+shift+q and that's what I see in console:

Traceback (most recent call last):
File "/Applications/Sublime Text.app/Contents/MacOS/sublime_plugin.py", line 812, in run_
return self.run(edit, **args)
File "consolewrap in xxx/Library/Application Support/Sublime Text 3/Installed Packages/Console Wrap for js.sublime-package", line 130, in run
File "consolewrap in xxx/Library/Application Support/Sublime Text 3/Installed Packages/Console Wrap for js.sublime-package", line 74, in is_log_string
TypeError: 'NoneType' object is not subscriptable

Console Wrap: not work in this file type source.js.dom

  • macOS v 10.1.25
  • Sublime Text 3 build 3126

Installed Console Wrap plugin and it was working fine till now but suddenly it stopped working (using Control + Shift + q keyboard shortcut ) and it gives error in gutter

Console Wrap: not work in this file type source.js.dom

my file extension is .js and using es6 syntax..

can someone shed light how to fix that? I have restarted the ST3 but no affect.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.