Skip to content

Commit

Permalink
fix: change the way we handle new lines in logger
Browse files Browse the repository at this point in the history
fix: change the way we handle new lines in logger
  • Loading branch information
mattallty committed Feb 26, 2017
1 parent aabee81 commit 635fa9b
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion lib/logger.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ CaporalTransport.prototype.log = function (level, msg, meta, callback) {
}
const levelInt = winston.levels[level];
const stdio = levelInt <= 1 ? 'stderr' : 'stdout';
process[stdio].write(msg + "\n");
process[stdio].write(msg);
callback(null, true, stdio);
};

Expand Down
2 changes: 1 addition & 1 deletion lib/program.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ class Program extends GetterSetter {
* @private
*/
fatalError(errObj) {
this.logger().error(errObj.message);
this.logger().error("\n" + errObj.message);
process.exit(2);
}

Expand Down
2 changes: 1 addition & 1 deletion tests/fatal-error.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ program.
describe("program.fataError()", () => {

it(`should call logger.error() and exit(2)`, () => {
const error = sinon.stub(logger, 'error').withArgs("foo");
const error = sinon.stub(logger, 'error').withArgs("\nfoo");
const exit = sinon.stub(process, 'exit').withArgs(2);

program.fatalError(new Error("foo"));
Expand Down
6 changes: 3 additions & 3 deletions tests/logger.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ describe('logger', () => {
const oldWrite = process.stdout.write;
process.stdout.write = write;

should(stripColor(logStr)).be.eql("foo\nfoo: bar\n");
should(stripColor(logStr)).be.eql("foo\nfoo: bar");
should(callback.called).be.ok();
should(oldWrite.called).be.ok();
});
Expand All @@ -44,7 +44,7 @@ describe('logger', () => {
const oldWrite = process.stderr.write;
process.stderr.write = write;

should(stripColor(logStr)).be.eql("foo\nfoo: bar\n");
should(stripColor(logStr)).be.eql("foo\nfoo: bar");
should(callback.called).be.ok();
should(oldWrite.called).be.ok();

Expand All @@ -65,7 +65,7 @@ describe('logger', () => {
const oldWrite = process.stdout.write;
process.stdout.write = write;

should(stripColor(logStr)).be.eql("foo\n");
should(stripColor(logStr)).be.eql("foo");
should(callback.called).be.ok();
should(oldWrite.called).be.ok();

Expand Down

0 comments on commit 635fa9b

Please sign in to comment.