Skip to content
This repository has been archived by the owner on Dec 8, 2022. It is now read-only.

Added colors to winston #244

Merged
merged 2 commits into from
Jul 25, 2017
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
2 changes: 1 addition & 1 deletion cli/e2e.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

const path = require('path');
const spawn = require('cross-spawn');
const logger = require('winston');
const logger = require('../utils/logger');
const portfinder = require('portfinder');
const HttpServer = require('http-server');
const selenium = require('selenium-standalone');
Expand Down
2 changes: 1 addition & 1 deletion cli/serve.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
/*jshint node: true*/
'use strict';

const logger = require('winston');
const portfinder = require('portfinder');

const logger = require('../utils/logger');
const assetsProcessor = require('../lib/assets-processor');

/**
Expand Down
2 changes: 1 addition & 1 deletion cli/utils/run-compiler.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*jshint node: true*/
'use strict';

const logger = require('winston');
const logger = require('../../utils/logger');

const runCompiler = (webpack, config) => {
const compiler = webpack(config);
Expand Down
2 changes: 1 addition & 1 deletion cli/version.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
'use strict';

const path = require('path');
const logger = require('winston');
const logger = require('../utils/logger');

/**
* Returns the version from package.json.
Expand Down
2 changes: 1 addition & 1 deletion config/sky-pages/sky-pages.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
const fs = require('fs-extra');
const path = require('path');
const merge = require('merge');
const logger = require('winston');
const logger = require('../../utils/logger');

/**
* Resolves a path given a root path and an array-like arguments object.
Expand Down
2 changes: 1 addition & 1 deletion config/webpack/serve.webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ const fs = require('fs');
const path = require('path');
const util = require('util');
const open = require('open');
const logger = require('winston');
const logger = require('../../utils/logger');
const webpackMerge = require('webpack-merge');
const NamedModulesPlugin = require('webpack/lib/NamedModulesPlugin');
const LoaderOptionsPlugin = require('webpack/lib/LoaderOptionsPlugin');
Expand Down
2 changes: 1 addition & 1 deletion index.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
/*jshint node: true*/
'use strict';

const logger = require('winston');
const webpack = require('webpack');
const WebpackDevServer = require('webpack-dev-server');
const logger = require('./utils/logger');
const config = require('./config/sky-pages/sky-pages.config');

module.exports = {
Expand Down
2 changes: 1 addition & 1 deletion loader/sky-processor/index.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*jshint node: true*/
'use strict';

const logger = require('winston');
const logger = require('../../utils/logger');
let plugins;

const getPluginContents = (skyPagesConfig) => {
Expand Down
2 changes: 1 addition & 1 deletion loader/sky-tslint/program.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
'use strict';

const tslint = require('tslint');
const logger = require('winston');
const logger = require('../../utils/logger');
let _program;

const getProgram = (tsconfigPath) => {
Expand Down
2 changes: 1 addition & 1 deletion test/cli-build-public-library.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
const mock = require('mock-require');
const fs = require('fs-extra');
const rimraf = require('rimraf');
const logger = require('winston');
const logger = require('../utils/logger');
const skyPagesConfigUtil = require('../config/sky-pages/sky-pages.config');

describe('cli build-public-library', () => {
Expand Down
2 changes: 1 addition & 1 deletion test/cli-build.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
'use strict';

const mock = require('mock-require');
const logger = require('winston');
const logger = require('../utils/logger');
const assetsProcessor = require('../lib/assets-processor');
const runtimeUtils = require('../utils/runtime-test-utils');

Expand Down
2 changes: 1 addition & 1 deletion test/cli-e2e.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@

const path = require('path');
const mock = require('mock-require');
const logger = require('winston');
const selenium = require('selenium-standalone');
const logger = require('../utils/logger');

describe('cli e2e', () => {
const PORT = 1234;
Expand Down
2 changes: 1 addition & 1 deletion test/cli-serve.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
'use strict';

const mock = require('mock-require');
const logger = require('winston');
const portfinder = require('portfinder');
const logger = require('../utils/logger');

describe('cli serve', () => {

Expand Down
2 changes: 1 addition & 1 deletion test/cli-utils-run-compiler.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
'use strict';

const mock = require('mock-require');
const logger = require('winston');
const logger = require('../utils/logger');

describe('cli utils run compiler', () => {
const requirePath = '../cli/utils/run-compiler';
Expand Down
2 changes: 1 addition & 1 deletion test/cli-version.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

const path = require('path');
const proxyquire = require('proxyquire');
const logger = require('winston');
const logger = require('../utils/logger');

describe('cli version', () => {
it('should return the version from package.json', () => {
Expand Down
2 changes: 1 addition & 1 deletion test/config-sky-pages.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
'use strict';

const fs = require('fs-extra');
const logger = require('winston');
const logger = require('../utils/logger');

describe('config sky-pages', () => {

Expand Down
2 changes: 1 addition & 1 deletion test/config-webpack-serve.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
'use strict';

const mock = require('mock-require');
const logger = require('winston');
const urlLibrary = require('url');
const logger = require('../utils/logger');
const runtimeUtils = require('../utils/runtime-test-utils');

describe('config webpack serve', () => {
Expand Down
2 changes: 1 addition & 1 deletion test/loader-processor.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
'use strict';

const mock = require('mock-require');
const logger = require('winston');
const logger = require('../utils/logger');

describe('SKY UX processor Webpack loader', () => {
const preloaderPath = '../loader/sky-processor/preload';
Expand Down
2 changes: 1 addition & 1 deletion test/sky-pages-out-skyux2.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
'use strict';

const mock = require('mock-require');
const logger = require('winston');
const logger = require('../utils/logger');

describe('@blackbaud/skyux-builder', () => {

Expand Down
29 changes: 29 additions & 0 deletions test/utils-logger.spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
/*jshint jasmine: true, node: true */
'use strict';

const mock = require('mock-require');

describe('logger', () => {
afterEach(() => {
mock.stopAll();
});

it('should configure a custom transport', () => {
let _transports;
let _colorize = false;
mock('winston', {
Logger: function (opts) {
_transports = opts.transports;
},
transports: {
Console: function (opts) {
_colorize = opts.colorize;
}
}
});

const logger = mock.reRequire('../utils/logger');
expect(_colorize).toEqual(true);
expect(_transports).toBeDefined();
});
});
17 changes: 17 additions & 0 deletions utils/logger.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
/*jshint node: true */
'use strict';

const winston = require('winston');

const logger = new winston.Logger({
transports: [
new winston.transports.Console({
level: 'debug',
handleExceptions: true,
json: false,
colorize: true
})
]
});

module.exports = logger;