Skip to content
This repository has been archived by the owner on Jan 18, 2019. It is now read-only.

Commit

Permalink
feat(verbose-logging): Add verbose/debug logging
Browse files Browse the repository at this point in the history
see #20
  • Loading branch information
hypery2k committed Jan 20, 2017
1 parent 27dc480 commit 296147c
Show file tree
Hide file tree
Showing 5 changed files with 43 additions and 18 deletions.
16 changes: 16 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,22 @@ Configure proxy:

### Advanced Usage

#### Debugging

If you need to debug the tests use the node-inspector:
```
npm run debug
node-inspector --web-port=8282
```

You can then open chrome at *http://127.0.0.1:8282/?port=5858* for debugging.

If you want to have verbose logging add NODE_DEBUG=holisticon_angular-common:

```
NODE_DEBUG=holisticon_angular-common npm run build
```

#### Multiple Entries

```javascript
Expand Down
12 changes: 10 additions & 2 deletions etc/helpers.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,18 @@
const DEBUG_ENV = 'holisticon_angular-common';
const path = require('path');
const util = require('util');
const debugLog = util.debuglog('@holisticon/angular-common/helpers');
const debugLog = util.debuglog(DEBUG_ENV);
const defaultAppConfig = require('./appConfig');
const providedAppConfig = require(process.env.APP_CONFIG || './appConfig');

// Helper functions
const ROOT = path.resolve(__dirname, '..');

function isDebug() {
var env = process.env || {};
return env.NODE_DEBUG === DEBUG_ENV ? true : false
}

function hasProcessFlag(flag) {
return process.argv.join('').indexOf(flag) > -1;
}
Expand Down Expand Up @@ -113,7 +119,7 @@ function mergeAppConfig(overwrittenConfig) { /*eslint complexity: [error, 22]*/
dist: appConfig.dist || path.resolve(distPath),
genPath: genPath,
junit: junit,
copy: appConfig.copy,
copy: appConfig.copy || defaultAppConfig.copy,
indexFiles: indexFiles,
gen: appConfig.gen || path.resolve(genPath),
chunks: appConfig.chunks || defaultAppConfig.chunks,
Expand All @@ -134,6 +140,8 @@ function getAppConfig() {
return mergeAppConfig(providedAppConfig);
}

exports.DEBUG_ENV = DEBUG_ENV;
exports.isDebug = isDebug;
exports.mergeAppConfig = mergeAppConfig;
exports.getAppConfig = getAppConfig;
exports.hasProcessFlag = hasProcessFlag;
Expand Down
31 changes: 16 additions & 15 deletions etc/webpack.common.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ const path = require('path');
const os = require('os');
const helpers = require('./helpers');
const appConfig = helpers.getAppConfig();
const debugLog = util.debuglog('@holisticon/angular-common/webpack.common');
const debugLog = util.debuglog(helpers.DEBUG_ENV);
const isDebug = helpers.isDebug();
// WEBPACK
const webpack = require('webpack');

Expand Down Expand Up @@ -36,19 +37,19 @@ var config = {

stats: {
// Add asset Information
assets: true,
assets: isDebug,
// Sort assets by a field
assetsSort: "field",
// Add information about cached (not built) modules
cached: true,
cached: isDebug,
// Add children information
children: true,
children: isDebug,
// Add chunk information (setting this to `false` allows for a less verbose output)
chunks: true,
chunks: isDebug,
// Add built modules information to chunk information
chunkModules: true,
chunkModules: isDebug,
// Add the origins of chunks and chunk merging info
chunkOrigins: true,
chunkOrigins: isDebug,
// Sort the chunks by a field
chunksSort: "field",
// Context directory for request shortening
Expand All @@ -58,23 +59,23 @@ var config = {
// Add details to errors (like resolving log)
errorDetails: true,
// Add the hash of the compilation
hash: true,
hash: isDebug,
// Add built modules information
modules: true,
modules: isDebug,
// Sort the modules by a field
modulesSort: "field",
// Add public path information
publicPath: true,
publicPath: isDebug,
// Add information about the reasons why modules are included
reasons: true,
reasons: isDebug,
// Add the source code of modules
source: true,
source: isDebug,
// Add timing information
timings: true,
timings: isDebug,
// Add webpack version information
version: true,
version: isDebug,
// Add warnings
warnings: true
warnings: isDebug
},
/*
* The entry point for the bundle
Expand Down
1 change: 0 additions & 1 deletion etc/webpack.dev.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
const util = require('util');
const helpers = require('./helpers');
const appConfig = helpers.getAppConfig();
const debugLog = util.debuglog('@holisticon/angular-common/webpack.dev');

// WEBPACK
const webpack = require('webpack');
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
"build": "npm run tslint && npm run tsc && cross-env NODE_ENV=production webpack",
"lite": "lite-server",
"test": "cross-env NODE_ENV=test jasmine-node test/*.spec.js --junitreport --output target/test-reports/ --verbose --noStack --color",
"debug": "node --debug-brk node_modules/jasmine-node/lib/jasmine-node/cli.js test/*.spec.js",
"e2e": "cd test && npm i && cd .. && karma start test/karma.conf.ci.js",
"watch-test": "cross-env NODE_ENV=test karma start",
"tslint": "tslint \"test/**/*.ts\" --exclude \"test/node_modules/**/*\"",
Expand Down

0 comments on commit 296147c

Please sign in to comment.