Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,16 @@ language: node_js
node_js:
- "6.*"

# https://github.com/andywer/leakage#travis-ci
addons:
apt:
sources:
- ubuntu-toolchain-r-test
packages:
- g++-4.8
before_install:
- if [[ $TRAVIS_OS_NAME == "linux" ]]; then export CXX=g++-4.8; fi

branches:
only:
- master
Expand Down
6 changes: 4 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,15 @@
"main": "dist/node.js",
"browser": "dist/client.js",
"scripts": {
"test": "npm run test:browser && npm run test:node",
"test": "npm run test:browser && npm run test:node && npm run test:leakage",
"tdd": "npm-run-all --parallel test:*:tdd",
"test:ci": "npm run test:browser && npm run test:node:ci",
"test:browser": "NODE_ENV=test karma start test/karma.conf.js",
"test:browser:tdd": "npm run test:browser -- --auto-watch --no-single-run",
"test:node": "NODE_ENV=test nyc mocha test/runner test/specs/**/*.js",
"test:node": "NODE_ENV=test nyc mocha test/runner test/specs/common/**/*.js",
"test:node:tdd": "npm run test:node -- --cache --watch",
"test:node:ci": "npm run test:node && nyc report --reporter=text-lcov | coveralls",
"test:leakage": "NODE_ENV=test mocha test/runner test/specs/leakage/**/*.js",
"test:bundle:tdd": "npm-run-all -l --parallel 'bundle:* -- --watch'",
"lint": "eslint --format ./node_modules/eslint-friendly-formatter --cache src test",
"clean": "rimraf dist && mkdirp dist",
Expand Down Expand Up @@ -104,6 +105,7 @@
"karma-sauce-launcher": "1.1.0",
"karma-sourcemap-loader": "0.3.7",
"karma-webpack": "1.8.1",
"leakage": "0.2.0",
"mkdirp": "0.5.1",
"mocha": "3.2.0",
"np": "2.12.0",
Expand Down
6 changes: 3 additions & 3 deletions src/client.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import bunyan from 'bunyan';
import hideSecrets from 'hide-secrets';
import { get, forEach } from 'lodash';
import { forEach } from 'lodash';

import scrub from './util/common/scrub';
import { assembleConfig, toBunyanConfig, BUNYAN_LOGGER_LEVELS } from './util/common/config';

import ClientConsoleLogger from './util/client/consoleLogger';
Expand Down Expand Up @@ -35,7 +35,7 @@ bunyan.prototype.child = function(options, simple) {
forEach(BUNYAN_LOGGER_LEVELS, (type) => {
const original = bunyan.prototype[type];
bunyan.prototype[type] = function(...args) {
const newArgs = args.map((arg) => hideSecrets(arg, { badWords: get(this.config, 'scrubFields', []) }));
const newArgs = args.map((arg) => scrub(arg, this.config));
return original.apply(this, newArgs);
}
});
Expand Down
6 changes: 3 additions & 3 deletions src/node.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import bunyan from 'bunyan';
import hideSecrets from 'hide-secrets';
import { get, forEach } from 'lodash';
import { forEach } from 'lodash';

import { assembleConfig, toBunyanConfig, BUNYAN_LOGGER_LEVELS } from './util/common/config';
import scrub from './util/common/scrub';

import Rollbar from 'rollbar';
import bunyanFormat from 'bunyan-format';
Expand Down Expand Up @@ -39,7 +39,7 @@ bunyan.prototype.child = function(options, simple) {
forEach(BUNYAN_LOGGER_LEVELS, (type) => {
const original = bunyan.prototype[type];
bunyan.prototype[type] = function(...args) {
const newArgs = args.map((arg) => hideSecrets(arg, { badWords: get(this.config, 'scrubFields', []) }));
const newArgs = args.map((arg) => scrub(arg, this.config));
return original.apply(this, newArgs);
}
});
Expand Down
5 changes: 5 additions & 0 deletions src/util/common/scrub.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import hideSecrets from 'hide-secrets';

export default function(obj, config = {}) {
return hideSecrets(obj, { badWords: config.scrubFields });
}
4 changes: 2 additions & 2 deletions test/browser.index.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,5 @@ global.Rollbar = {
};

// require all `/test/specs/**/*.js`
const testsContext = require.context('./specs/', true, /\.js$/);
testsContext.keys().forEach(testsContext);
const testsContext = require.context('./specs/common', true, /\.js$/);
testsContext.keys().forEach(testsContext);
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Require the package. For client tests, webpack should
// resolve to the browser version automatically.
import Logger from '../../';
import TestLogger from '../testLogger';
import Logger from '../../../';
import TestLogger from '../../testLogger';

// Logentries validates the token it is passed,
// here is a fake one in an acceptable format
Expand All @@ -13,7 +13,6 @@ describe('we-js-logger', () => {
expect(new Logger()).to.be.ok;
});


describe('options', () => {
it('accepts a name', () => {
const name = 'WeTest!';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import Logger from '../../';
import TestLogger from '../testLogger';
import Logger from '../../../';
import TestLogger from '../../testLogger';

import createRequestLogger from '../../src/util/server/requestLogger';
import createRequestLogger from '../../../src/util/server/requestLogger';

// Only run these tests in node
// FIXME find a better way to do this. Should we use `env-universal`?
Expand Down Expand Up @@ -135,4 +135,4 @@ if (typeof document === 'undefined') {
});
});
});
}
}
27 changes: 27 additions & 0 deletions test/specs/leakage/logger.spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import { iterate } from 'leakage';
import Logger from '../../../';


describe('Heap Tests - we-js-logger', function() {
let log;

beforeEach(() => {
log = new Logger({ stdout: false });
});

it('does not leak when logging 1k times', function() {
this.timeout(20000);
iterate(1000, () => {
log.info('log time');
});
});

it('does not leak when building and logging child 1k times', function() {
this.timeout(20000);
iterate(1000, () => {
const child = log.child();
child.info('child time');
});
});
});