Mark methods as deprecated and warn the user when they're called. Forked from brianc/node-deprecate.
var complain = require('complain');
Call complain
within a function you are deprecating. It will spit out all the messages to the console the first time and only the first time the method is called.
1 │ var complain = require('complain');
2 │
3 │ var someDeprecatedFunction = function() {
4 │ complain('someDeprecatedFunction() is deprecated');
5 │ };
6 │
… │ // …
30 │
31 │ someDeprecatedFunction();
program output:
location
: a string in the format ${filepath}:${line}:${column}
indicating where the deprecated function was called from. Setting this to false
disables outputting the location and will only log the message once.
Deprecates a method on an object:
complain.method(console, 'log', 'You should not log.');
Deprecates a function and returns it:
console.log = complain.fn(console.log, 'You should not log.');
Set to false
to disable color output. Set to true
to force color output. Defaults to the value of complain.stream.isTTY
.
Controls the colors used when logging. Default value:
{
warning: '\x1b[31;1m', // red, bold
message: false, // use system color
location: '\u001b[90m' // gray
}
How the default looks on a dark background vs. a light background:
When true
, do nothing when the complain method is called.
The to which output is written. Defaults to process.stderr
.
The function used to log, by default this function writes to complain.stream
and falls back to console.warn
.
You can replace this with your own logging method.
MIT