flatiron/winston — pull request #427 by slezica (2014-07-30 08:12:16+00:00)
Title: Optional per-transport custom formatting

## Rationale

Winston provides a default log formatter in the form of `common.log()`, which can be configured but not overridden.

This tiny patch gives the user the ability to override the default formatting method with a custom function. It works on a per-Transport basis, by setting the `formatter` option on construction, or the `formatter` property later on.

## Modifications

- Implemented `Transport.formatMessage()` as a base formatter to inherit. It wraps `common.log()`, unless `this.formatter` is set.

- Modified the `log()` method of the 4 `Transport` subclasses to use `formatMessage()` instead of calling `common.log()` directly.

- Added the `formatter` option to the 4 `Transport` subclasses.

- Added basic test coverage.

## Considerations

- Coding style was carefully maintained, though the blend may not be perfect.

- Unfortunately, there is no way of implementing this functionality across `Transports` without modifying each class. All 4 `Transports` were adapted, and additional `Transports` in other repositories would need to explicitly support this by calling `this.formatMessage()` instead of `common.log()`.

- Test coverage boils down to a single test case. In my opinion, it's enough, but yours may differ.

- Very good work on Winston. Flexible, featureful and clean. The code is well organized and commented. Writing this patch was a pleasure.