@deephaven/jsapi-shim
Advanced tools
Comparing version 0.2.1 to 0.3.0
@@ -18,2 +18,3 @@ export default DhPropTypes; | ||
onLogMessage: PropTypes.Requireable<(...args: any[]) => any>; | ||
getTable: PropTypes.Validator<(...args: any[]) => any>; | ||
runCode: PropTypes.Validator<(...args: any[]) => any>; | ||
@@ -20,0 +21,0 @@ }>>; |
@@ -71,2 +71,3 @@ import PropTypes from 'prop-types'; | ||
onLogMessage: PropTypes.func, | ||
getTable: PropTypes.func.isRequired, | ||
runCode: PropTypes.func.isRequired, | ||
@@ -73,0 +74,0 @@ }); |
{ | ||
"name": "@deephaven/jsapi-shim", | ||
"version": "0.2.1", | ||
"version": "0.3.0", | ||
"description": "Deephaven JSAPI Shim", | ||
@@ -31,4 +31,2 @@ "author": "Deephaven Data Labs LLC", | ||
"start": "cross-env NODE_ENV=development npm run watch", | ||
"test": "jest --watch", | ||
"test:ci": "jest --ci", | ||
"predeploy": "cd example && npm install && npm run build", | ||
@@ -43,13 +41,10 @@ "deploy": "gh-pages -d example/build" | ||
"devDependencies": { | ||
"@babel/cli": "^7.14.3", | ||
"@babel/cli": "^7.14.8", | ||
"@babel/core": "7.12.3", | ||
"@types/jest": "^26.0.23", | ||
"babel-loader": "8.1.0", | ||
"classnames": "^2.3.1", | ||
"cross-env": "^7.0.2", | ||
"jest": "26.6.0", | ||
"npm-run-all": "^4.1.5", | ||
"prop-types": "^15.7.2", | ||
"rimraf": "^3.0.2", | ||
"ts-jest": "^26.5.6", | ||
"typescript": "^4.3.2" | ||
@@ -63,3 +58,3 @@ }, | ||
}, | ||
"gitHead": "7356846da144a095b82eaf49780ce495c578e1fc" | ||
"gitHead": "1dd8d174cf5a65fdc78ab8d7864abc64883e0b03" | ||
} |
@@ -1,4 +0,4 @@ | ||
# @deephaven/log | ||
# @deephaven/jsapi-shim | ||
A logging library that can be used for modules to log different levels of logging, intercept console logging, and store a history of logs in memory for later consumption or exporting. | ||
A shim library that is used to import the global `dh` object as a module, and provide some useful `PropTypes`. | ||
@@ -8,3 +8,3 @@ ## Install | ||
```bash | ||
npm install --save @deephaven/log | ||
npm install --save @deephaven/jsapi-shim | ||
``` | ||
@@ -15,31 +15,24 @@ | ||
```javascript | ||
import Log from '@deephaven/log' | ||
import dh, { PropTypes as APIPropTypes } from '@deephaven/jsapi-shim' | ||
// Set the level of logging you want in your app (default is INFO). This can be changed dynamically. | ||
import { LoggerLevel } from '@deephaven/log' | ||
Log.setLogLevel(LoggerLevel.DEBUG2); | ||
class MyComponent { | ||
componentDidMount() { | ||
const { session } = this.props; | ||
session.addEventListener( | ||
dh.IdeSession.EVENT_COMMANDSTARTED, | ||
event => { | ||
console.log('Command started event', event); | ||
} | ||
); | ||
} | ||
// You can log messages directly without a module by calling the logging methods directly | ||
Log.info('basic info level log message'); | ||
render() { | ||
return null; | ||
} | ||
} | ||
// Alternatively, create a log module to group log messages. All messages logged to this module will be prefixed with `[MyModuleName]`. | ||
const log = Log.module('MyModuleName'); | ||
MyComponent.proptypes = { | ||
session: APIPropTypes.IdeSession.isRequired, | ||
} | ||
// The different possible logging methods. If the log level is set lower than the recorded method, it will not be logged. | ||
log.debug2('debug2 level log message'); | ||
log.debug('debug level log message'); | ||
log.info('info level log message'); | ||
log.log('alias for log.info'); | ||
log.warn('warning level log message'); | ||
log.error('error level log message'); | ||
// Enable the LogProxy to intercept all console messages | ||
import { LogProxy } from '@deephaven/log'; | ||
const logProxy = new LogProxy(); | ||
logProxy.enable(); | ||
// Enable the LogHistory to store all log messages in memory for later consumption or exporting (requires LogProxy to be enabled already) | ||
import { LogHistory } from '@deephaven/log'; | ||
const logHistory = new LogHistory(logProxy); | ||
logHistory.enable(); | ||
``` | ||
export default MyComponent; |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
9
203
62276
36