Skip to content

Commit

Permalink
[breaking] Removed Logger.prototype.extend functionality (more main…
Browse files Browse the repository at this point in the history
…tainable without it).
  • Loading branch information
indexzero committed Oct 29, 2015
1 parent a470ab5 commit 8cb7048
Show file tree
Hide file tree
Showing 4 changed files with 1 addition and 57 deletions.
15 changes: 0 additions & 15 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ There are two different ways to use winston: directly via the default logger, or
* [Events and Callbacks in Winston](#events-and-callbacks-in-winston)
* [Working with multiple Loggers in winston](#working-with-multiple-loggers-in-winston)
* [Using winston in a CLI tool](#using-winston-in-a-cli-tool)
* [Extending another object with Logging](#extending-another-object-with-logging)
* [Filters and Rewriters](#filters-and-rewriters)
* [Adding Custom Transports](#adding-custom-transports)
* [Installation](#installation)
Expand Down Expand Up @@ -639,20 +638,6 @@ Configuring output for this style is easy, just use the `.cli()` method on `wins
logger.cli();
```

### Extending another object with Logging
Often in a given code base with lots of Loggers it is useful to add logging methods to a different object so that these methods can be called with less syntax. Winston exposes this functionality via the 'extend' method:

``` js
var myObject = {};

logger.extend(myObject);

//
// You can now call logger methods on 'myObject'
//
myObject.info("127.0.0.1 - there's no place like home");
```

### Filters and Rewriters
Filters allow modifying the contents of **log messages**, and Rewriters allow modifying the contents of **log meta** e.g. to mask data that should not appear in logs.

Expand Down
17 changes: 0 additions & 17 deletions lib/winston/logger.js
Original file line number Diff line number Diff line change
Expand Up @@ -81,23 +81,6 @@ var Logger = exports.Logger = function (options) {
//
util.inherits(Logger, events.EventEmitter);

//
// ### function extend (target)
// #### @target {Object} Target to extend.
// Extends the target object with a 'log' method
// along with a method for each level in this instance.
//
Logger.prototype.extend = function (target) {
var self = this;
['log', 'profile', 'startTimer'].concat(Object.keys(this.levels)).forEach(function (method) {
target[method] = function () {
return self[method].apply(self, arguments);
};
});

return this;
};

//
// ### function log (level, msg, [meta], callback)
// #### @level {string} Level at which to log the message.
Expand Down
12 changes: 0 additions & 12 deletions test/logger-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,18 +74,6 @@ vows.describe('winton/logger').addBatch({
"the log() method should throw an error": function (logger) {
assert.throws(function () { logger.log('anything') }, Error);
},
"the extend() method called on an empty object": {
topic: function (logger) {
var empty = {};
logger.extend(empty);
return empty;
},
"should define the appropriate methods": function (extended) {
['log', 'profile', 'startTimer'].concat(Object.keys(winston.config.npm.levels)).forEach(function (method) {
assert.isFunction(extended[method]);
});
}
},
"the add() method with a supported transport": {
topic: function (logger) {
return logger.add(winston.transports.Console);
Expand Down
14 changes: 1 addition & 13 deletions test/winston-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,19 +47,7 @@ vows.describe('winston').addBatch({
},
"the log() method": helpers.testNpmLevels(winston, "should respond without an error", function (err) {
assert.isNull(err);
}),
"the extend() method called on an empty object": {
topic: function (logger) {
var empty = {};
winston.extend(empty);
return empty;
},
"should define the appropriate methods": function (extended) {
['log', 'profile', 'startTimer'].concat(Object.keys(winston.config.npm.levels)).forEach(function (method) {
assert.isFunction(extended[method]);
});
}
}
})
}
}).addBatch({
"The winston module": {
Expand Down

0 comments on commit 8cb7048

Please sign in to comment.