Last Updated: February 25, 2016
· ncthis

A snippet for initializing debug on sublime text

I use debug pretty religously. This is an example initialisation:

const log = require('debug')('MyApp:FooFile.js:log');
const error = require('debug')('MyApp:FooFile.js:error');

But doing that for each FooFile.js manually is cumbersome at best. So, I use this snippet:

  <!-- Example: Hello, ${1:this} is a ${2:snippet}. -->
const log = require('debug')('$TM_FILENAME:log');
const error = require('debug')('$TM_FILENAME:error');
  <!-- Optional: Set a tabTrigger to define how to trigger the snippet -->
  <!-- Optional: Set a scope to limit where the snippet will trigger -->

And then you can do dbg (whatever's inside tabTrigger element), and then You have initiated logs!

Note: I originally published this here.