-
Notifications
You must be signed in to change notification settings - Fork 456
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #904 from mikehazell/pr/logging
Replace console.log calls with debug
- Loading branch information
Showing
38 changed files
with
581 additions
and
217 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,25 @@ | ||
const webpack = require('webpack'); | ||
const merge = require('./merge'); | ||
const baseConfig = require('./webpack-base'); | ||
const UglifyJSPlugin = require('uglifyjs-webpack-plugin'); | ||
|
||
const prodConfig = { | ||
output: { | ||
filename: '[name].min.js' | ||
filename: '[name].min.js', | ||
}, | ||
mode: "production", | ||
mode: 'production', | ||
optimization: { | ||
minimizer: [ | ||
new UglifyJSPlugin({ | ||
sourceMap: true | ||
}) | ||
] | ||
sourceMap: true, | ||
}), | ||
], | ||
}, | ||
plugins: [ | ||
new webpack.DefinePlugin({ | ||
'process.env.NODE_ENV': JSON.stringify('production'), | ||
}), | ||
], | ||
}; | ||
|
||
module.exports = merge(baseConfig, prodConfig); | ||
module.exports = merge(baseConfig, prodConfig); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
# Debugging | ||
|
||
Cornerstone Tools is using the [`debug`](https://github.com/visionmedia/debug/) library for logging debug information. | ||
|
||
By default, in the minified "production" build of cornerstone tools, only | ||
errors will be logged to the console. | ||
|
||
When using the un-minified or "development" build, you may also see some | ||
warnings logged to the console in some scenarios. | ||
|
||
But there is more log information available if you need it. | ||
|
||
## Turing debug logs on and off | ||
|
||
`cornerstoneTools` exports `enableLogger` and `disableLogger` methods as top level api methods. | ||
|
||
`enableLogger` takes a scoping string with which you can specify scopes to be included / excluded. | ||
|
||
Multiple scopes are comma separated. Excluding a scope is done by prefixing with `-`. You can use the `*` match against many scopes. | ||
|
||
```js | ||
import csTools from 'cornerstone-tools'; | ||
|
||
// Enable logging | ||
csTools.enableLogger(); | ||
// defaults to "cornerstoneTools:*" which will print all logs from the cornerstoneTools package | ||
|
||
// This is just some sugar ontop of the debug library. You can enable all | ||
// debug logging – including things outside of cornerstoneTools | ||
csTools.enableLogger('*'); | ||
|
||
// Only show logs from setToolMode.js | ||
csTools.enableLogger('cornerstoneTools:store:setToolMode'); | ||
|
||
// Show all logs, but exclude the eventDispatchers (which can be a bit noisy) | ||
csTools.enableLogger('cornerstoneTools:*,-cornerstoneTools:eventDispatchers:*'); | ||
|
||
// Disable logging | ||
const prevSettings = csTools.disableLogger(); | ||
// `disableLogger` returns a string of the previous settings in case | ||
// you wanted to toggle logging off and back on later. | ||
|
||
// Eg. this would re-enable the previous settings | ||
csTools.enableLogging(prevSettings); | ||
``` | ||
|
||
As this is based on the wonderful `debug` library, you can also enable/disable | ||
the logger when you don't have access to `csTools` by using `localStorage`. | ||
|
||
```js | ||
// This will enable all cornerstoneTools logs | ||
localStorage.setItem('debug', 'cornerstoneTools:*'); | ||
// You will need to refresh the browser for this setting to take effect | ||
``` |
Oops, something went wrong.