Permalink
Browse files

upgrade to Rollbar 2.x

  • Loading branch information...
i8ramin committed Nov 5, 2017
1 parent 5f871cc commit efef2983b1e8937998c346eea57d5785651790e0
Showing with 7,499 additions and 119 deletions.
  1. +106 −106 API.md
  2. +3 −4 README.md
  3. +1 −1 package.json
  4. +5 −1 src/node.js
  5. +12 −7 src/util/server/rollbarLogger.js
  6. +7,372 −0 yarn.lock
View
212 API.md
@@ -3,14 +3,6 @@
### Table of Contents
- [ClientLogger](#clientlogger)
- [logForLevel](#logforlevel)
- [logIt](#logit)
- [BUNYAN_CONFIG_FIELDS](#bunyan_config_fields)
- [DEFAULT_ROOT_FIELDS](#default_root_fields)
- [BUNYAN_LOGGER_LEVELS](#bunyan_logger_levels)
- [DEFAULT_CONFIG](#default_config)
- [assembleConfig](#assembleconfig)
- [toBunyanConfig](#tobunyanconfig)
- [ClientConsoleLogger](#clientconsolelogger)
- [write](#write)
- [ClientLogentriesLogger](#clientlogentrieslogger)
@@ -20,6 +12,14 @@
- [bunyanToRollbarLevelMap](#bunyantorollbarlevelmap)
- [bunyanLevelToRollbarLevelName](#bunyanleveltorollbarlevelname)
- [NodeLogger](#nodelogger)
- [BUNYAN_CONFIG_FIELDS](#bunyan_config_fields)
- [DEFAULT_ROOT_FIELDS](#default_root_fields)
- [BUNYAN_LOGGER_LEVELS](#bunyan_logger_levels)
- [DEFAULT_CONFIG](#default_config)
- [assembleConfig](#assembleconfig)
- [toBunyanConfig](#tobunyanconfig)
- [logForLevel](#logforlevel)
- [logIt](#logit)
- [ServerRollbarLogger](#serverrollbarlogger)
- [write](#write-3)
- [ServerLogentriesLogger](#serverlogentrieslogger)
@@ -28,7 +28,7 @@
## ClientLogger
[src/client.js:80-86](https://github.com/wework/we-js-logger/blob/4dce96b7397de3ebfcf19c089241c7841883d5e9/src/client.js#L80-L86 "Source code on GitHub")
[src/client.js:80-86](https://github.com/wework/we-js-logger/blob/5f871cc8a67a2dd316a4a294b5d68f4a17968f72/src/client.js#L80-L86 "Source code on GitHub")
A logger than can be used in browsers
@@ -38,98 +38,15 @@ A logger than can be used in browsers
- `logger` **[Object](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object)?** an instance of a `bunyan` logger to use internally.
this is meant to be used by the `child` method.
## logForLevel
[src/util/common/logForLevel.js:10-22](https://github.com/wework/we-js-logger/blob/4dce96b7397de3ebfcf19c089241c7841883d5e9/src/util/common/logForLevel.js#L10-L22 "Source code on GitHub")
Creates a log method for a particular level
**Parameters**
- `level` **[String](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)**
Returns **[Function](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/function)**
## logIt
[src/util/common/logForLevel.js:19-21](https://github.com/wework/we-js-logger/blob/4dce96b7397de3ebfcf19c089241c7841883d5e9/src/util/common/logForLevel.js#L19-L21 "Source code on GitHub")
Log at a level.
Must be bound to a logger instance.
**Parameters**
- `args` **any**
Returns **[undefined](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/undefined)**
## BUNYAN_CONFIG_FIELDS
[src/util/common/config.js:9-14](https://github.com/wework/we-js-logger/blob/4dce96b7397de3ebfcf19c089241c7841883d5e9/src/util/common/config.js#L9-L14 "Source code on GitHub")
Config keys that should always be passed to
`bunyan.createLogger`
## DEFAULT_ROOT_FIELDS
[src/util/common/config.js:22-25](https://github.com/wework/we-js-logger/blob/4dce96b7397de3ebfcf19c089241c7841883d5e9/src/util/common/config.js#L22-L25 "Source code on GitHub")
Whitelist of extra config keys that should be
passed to `bunyan.createLogger` to form
root logger fields.
## BUNYAN_LOGGER_LEVELS
[src/util/common/config.js:32-32](https://github.com/wework/we-js-logger/blob/4dce96b7397de3ebfcf19c089241c7841883d5e9/src/util/common/config.js#L32-L32 "Source code on GitHub")
Array of bunyan's different log levels.
<https://github.com/trentm/node-bunyan#levels>
## DEFAULT_CONFIG
[src/util/common/config.js:35-47](https://github.com/wework/we-js-logger/blob/4dce96b7397de3ebfcf19c089241c7841883d5e9/src/util/common/config.js#L35-L47 "Source code on GitHub")
## assembleConfig
[src/util/common/config.js:60-67](https://github.com/wework/we-js-logger/blob/4dce96b7397de3ebfcf19c089241c7841883d5e9/src/util/common/config.js#L60-L67 "Source code on GitHub")
Merges config with DEFAULT_CONFIG, and appends passed in streams
with pre-configured streams for the runtime.
This is used to configure this library, not bunyan as it has a lot of
extra information. See `toBunyanConfig` below.
**Parameters**
- `config` **[Object](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object)**
- `getStreamsForRuntime` **[Function](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/function)** returns appended config.streams
Returns **[Object](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object)** runtimeConfig
## toBunyanConfig
[src/util/common/config.js:78-80](https://github.com/wework/we-js-logger/blob/4dce96b7397de3ebfcf19c089241c7841883d5e9/src/util/common/config.js#L78-L80 "Source code on GitHub")
Create a config objct for bunyan from a full `we-js-logger` config object.
Extra keys passed to `bunyan.createLogger` become root logger fields, pass
a custom `config.rootFields` to control this behavior
**Parameters**
- `config` **[Object](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object)**
- `config.rootFields` **[Array](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array)&lt;[String](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)>** extra fields to pass to bunyan
Returns **[Object](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object)** config for bunyan.createLogger
## ClientConsoleLogger
[src/util/client/consoleLogger.js:9-9](https://github.com/wework/we-js-logger/blob/4dce96b7397de3ebfcf19c089241c7841883d5e9/src/util/client/consoleLogger.js#L9-L9 "Source code on GitHub")
[src/util/client/consoleLogger.js:9-9](https://github.com/wework/we-js-logger/blob/5f871cc8a67a2dd316a4a294b5d68f4a17968f72/src/util/client/consoleLogger.js#L9-L9 "Source code on GitHub")
Pretty logging to `console` for client applications
### write
[src/util/client/consoleLogger.js:16-48](https://github.com/wework/we-js-logger/blob/4dce96b7397de3ebfcf19c089241c7841883d5e9/src/util/client/consoleLogger.js#L16-L48 "Source code on GitHub")
[src/util/client/consoleLogger.js:16-48](https://github.com/wework/we-js-logger/blob/5f871cc8a67a2dd316a4a294b5d68f4a17968f72/src/util/client/consoleLogger.js#L16-L48 "Source code on GitHub")
Transport to `console`
@@ -141,7 +58,7 @@ Returns **[undefined](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Re
## ClientLogentriesLogger
[src/util/client/logentriesLogger.js:10-23](https://github.com/wework/we-js-logger/blob/4dce96b7397de3ebfcf19c089241c7841883d5e9/src/util/client/logentriesLogger.js#L10-L23 "Source code on GitHub")
[src/util/client/logentriesLogger.js:10-23](https://github.com/wework/we-js-logger/blob/5f871cc8a67a2dd316a4a294b5d68f4a17968f72/src/util/client/logentriesLogger.js#L10-L23 "Source code on GitHub")
Custom bunyan stream that transports to Logentries from client applications
@@ -155,7 +72,7 @@ Custom bunyan stream that transports to Logentries from client applications
### write
[src/util/client/logentriesLogger.js:30-37](https://github.com/wework/we-js-logger/blob/4dce96b7397de3ebfcf19c089241c7841883d5e9/src/util/client/logentriesLogger.js#L30-L37 "Source code on GitHub")
[src/util/client/logentriesLogger.js:30-37](https://github.com/wework/we-js-logger/blob/5f871cc8a67a2dd316a4a294b5d68f4a17968f72/src/util/client/logentriesLogger.js#L30-L37 "Source code on GitHub")
Transport logs to Logentries
@@ -167,7 +84,7 @@ Returns **[undefined](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Re
## ClientRollbarLogger
[src/util/client/rollbarLogger.js:19-35](https://github.com/wework/we-js-logger/blob/4dce96b7397de3ebfcf19c089241c7841883d5e9/src/util/client/rollbarLogger.js#L19-L35 "Source code on GitHub")
[src/util/client/rollbarLogger.js:19-35](https://github.com/wework/we-js-logger/blob/5f871cc8a67a2dd316a4a294b5d68f4a17968f72/src/util/client/rollbarLogger.js#L19-L35 "Source code on GitHub")
Custom rollbar stream that transports to logentries from a browser
Wortks with a global Rollbar instance that is already initialized.
@@ -187,7 +104,7 @@ integrating Rollbar in client apps
### write
[src/util/client/rollbarLogger.js:42-48](https://github.com/wework/we-js-logger/blob/4dce96b7397de3ebfcf19c089241c7841883d5e9/src/util/client/rollbarLogger.js#L42-L48 "Source code on GitHub")
[src/util/client/rollbarLogger.js:42-48](https://github.com/wework/we-js-logger/blob/5f871cc8a67a2dd316a4a294b5d68f4a17968f72/src/util/client/rollbarLogger.js#L42-L48 "Source code on GitHub")
Transport logs to Rollbar
@@ -199,15 +116,15 @@ Returns **[undefined](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Re
## bunyanToRollbarLevelMap
[src/util/common/rollbar.js:11-18](https://github.com/wework/we-js-logger/blob/4dce96b7397de3ebfcf19c089241c7841883d5e9/src/util/common/rollbar.js#L11-L18 "Source code on GitHub")
[src/util/common/rollbar.js:11-18](https://github.com/wework/we-js-logger/blob/5f871cc8a67a2dd316a4a294b5d68f4a17968f72/src/util/common/rollbar.js#L11-L18 "Source code on GitHub")
Map of bunyan log levels to Rollbar levels
<https://github.com/trentm/node-bunyan#levels>
<https://rollbar.com/docs/notifier/rollbar.js/api/#rollbardebuginfowarnwarningerrorcritical>
## bunyanLevelToRollbarLevelName
[src/util/common/rollbar.js:25-28](https://github.com/wework/we-js-logger/blob/4dce96b7397de3ebfcf19c089241c7841883d5e9/src/util/common/rollbar.js#L25-L28 "Source code on GitHub")
[src/util/common/rollbar.js:25-28](https://github.com/wework/we-js-logger/blob/5f871cc8a67a2dd316a4a294b5d68f4a17968f72/src/util/common/rollbar.js#L25-L28 "Source code on GitHub")
Convert bunyan log level to rollbar level. Defaults to 'error'.
@@ -219,7 +136,7 @@ Returns **[String](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Refer
## NodeLogger
[src/node.js:68-78](https://github.com/wework/we-js-logger/blob/4dce96b7397de3ebfcf19c089241c7841883d5e9/src/node.js#L68-L78 "Source code on GitHub")
[src/node.js:68-80](https://github.com/wework/we-js-logger/blob/5f871cc8a67a2dd316a4a294b5d68f4a17968f72/src/node.js#L68-L80 "Source code on GitHub")
A logger than can be used in node processes
@@ -229,9 +146,92 @@ A logger than can be used in node processes
- `logger` **[Object](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object)?** an instance of a `bunyan` logger to use internally.
this is meant to be used by the `child` method.
## BUNYAN_CONFIG_FIELDS
[src/util/common/config.js:9-14](https://github.com/wework/we-js-logger/blob/5f871cc8a67a2dd316a4a294b5d68f4a17968f72/src/util/common/config.js#L9-L14 "Source code on GitHub")
Config keys that should always be passed to
`bunyan.createLogger`
## DEFAULT_ROOT_FIELDS
[src/util/common/config.js:22-25](https://github.com/wework/we-js-logger/blob/5f871cc8a67a2dd316a4a294b5d68f4a17968f72/src/util/common/config.js#L22-L25 "Source code on GitHub")
Whitelist of extra config keys that should be
passed to `bunyan.createLogger` to form
root logger fields.
## BUNYAN_LOGGER_LEVELS
[src/util/common/config.js:32-32](https://github.com/wework/we-js-logger/blob/5f871cc8a67a2dd316a4a294b5d68f4a17968f72/src/util/common/config.js#L32-L32 "Source code on GitHub")
Array of bunyan's different log levels.
<https://github.com/trentm/node-bunyan#levels>
## DEFAULT_CONFIG
[src/util/common/config.js:35-47](https://github.com/wework/we-js-logger/blob/5f871cc8a67a2dd316a4a294b5d68f4a17968f72/src/util/common/config.js#L35-L47 "Source code on GitHub")
## assembleConfig
[src/util/common/config.js:60-67](https://github.com/wework/we-js-logger/blob/5f871cc8a67a2dd316a4a294b5d68f4a17968f72/src/util/common/config.js#L60-L67 "Source code on GitHub")
Merges config with DEFAULT_CONFIG, and appends passed in streams
with pre-configured streams for the runtime.
This is used to configure this library, not bunyan as it has a lot of
extra information. See `toBunyanConfig` below.
**Parameters**
- `config` **[Object](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object)**
- `getStreamsForRuntime` **[Function](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/function)** returns appended config.streams
Returns **[Object](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object)** runtimeConfig
## toBunyanConfig
[src/util/common/config.js:78-80](https://github.com/wework/we-js-logger/blob/5f871cc8a67a2dd316a4a294b5d68f4a17968f72/src/util/common/config.js#L78-L80 "Source code on GitHub")
Create a config objct for bunyan from a full `we-js-logger` config object.
Extra keys passed to `bunyan.createLogger` become root logger fields, pass
a custom `config.rootFields` to control this behavior
**Parameters**
- `config` **[Object](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object)**
- `config.rootFields` **[Array](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array)&lt;[String](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)>** extra fields to pass to bunyan
Returns **[Object](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object)** config for bunyan.createLogger
## logForLevel
[src/util/common/logForLevel.js:10-22](https://github.com/wework/we-js-logger/blob/5f871cc8a67a2dd316a4a294b5d68f4a17968f72/src/util/common/logForLevel.js#L10-L22 "Source code on GitHub")
Creates a log method for a particular level
**Parameters**
- `level` **[String](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)**
Returns **[Function](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/function)**
## logIt
[src/util/common/logForLevel.js:19-21](https://github.com/wework/we-js-logger/blob/5f871cc8a67a2dd316a4a294b5d68f4a17968f72/src/util/common/logForLevel.js#L19-L21 "Source code on GitHub")
Log at a level.
Must be bound to a logger instance.
**Parameters**
- `args` **any**
Returns **[undefined](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/undefined)**
## ServerRollbarLogger
[src/util/server/rollbarLogger.js:10-17](https://github.com/wework/we-js-logger/blob/4dce96b7397de3ebfcf19c089241c7841883d5e9/src/util/server/rollbarLogger.js#L10-L17 "Source code on GitHub")
[src/util/server/rollbarLogger.js:10-17](https://github.com/wework/we-js-logger/blob/5f871cc8a67a2dd316a4a294b5d68f4a17968f72/src/util/server/rollbarLogger.js#L10-L17 "Source code on GitHub")
Custom bunyan stream that transports to Rollbar from a node process.
See <https://rollbar.com/docs/notifier/node_rollbar/> for integration details
@@ -245,7 +245,7 @@ See <https://rollbar.com/docs/notifier/node_rollbar/> for integration details
### write
[src/util/server/rollbarLogger.js:27-37](https://github.com/wework/we-js-logger/blob/4dce96b7397de3ebfcf19c089241c7841883d5e9/src/util/server/rollbarLogger.js#L27-L37 "Source code on GitHub")
[src/util/server/rollbarLogger.js:27-37](https://github.com/wework/we-js-logger/blob/5f871cc8a67a2dd316a4a294b5d68f4a17968f72/src/util/server/rollbarLogger.js#L27-L37 "Source code on GitHub")
handles `err` and `req` properties, attaches any custom data,
and calls the appropriate Rollbar method.
@@ -258,7 +258,7 @@ Returns **[undefined](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Re
## ServerLogentriesLogger
[src/util/server/logentriesLogger.js:10-20](https://github.com/wework/we-js-logger/blob/4dce96b7397de3ebfcf19c089241c7841883d5e9/src/util/server/logentriesLogger.js#L10-L20 "Source code on GitHub")
[src/util/server/logentriesLogger.js:10-20](https://github.com/wework/we-js-logger/blob/5f871cc8a67a2dd316a4a294b5d68f4a17968f72/src/util/server/logentriesLogger.js#L10-L20 "Source code on GitHub")
Custom bunyan stream that transports to logentries from a node process
@@ -276,7 +276,7 @@ Returns **[Object](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Refer
## createRequestLogger
[src/util/server/requestLogger.js:12-48](https://github.com/wework/we-js-logger/blob/4dce96b7397de3ebfcf19c089241c7841883d5e9/src/util/server/requestLogger.js#L12-L48 "Source code on GitHub")
[src/util/server/requestLogger.js:12-48](https://github.com/wework/we-js-logger/blob/5f871cc8a67a2dd316a4a294b5d68f4a17968f72/src/util/server/requestLogger.js#L12-L48 "Source code on GitHub")
Create a request loging express middleware
@@ -292,7 +292,7 @@ Returns **[Function](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Ref
## requestLoggerMiddleware
[src/util/server/requestLogger.js:24-47](https://github.com/wework/we-js-logger/blob/4dce96b7397de3ebfcf19c089241c7841883d5e9/src/util/server/requestLogger.js#L24-L47 "Source code on GitHub")
[src/util/server/requestLogger.js:24-47](https://github.com/wework/we-js-logger/blob/5f871cc8a67a2dd316a4a294b5d68f4a17968f72/src/util/server/requestLogger.js#L24-L47 "Source code on GitHub")
Request Logger Middleware
Adds base logging to every request
View
@@ -76,14 +76,13 @@ Providing the `Logger` constructor a `logentriesToken` option enables this trans
# Rollbar Integration
## Node
For node usage, this library will initialize Rollbar.
See https://rollbar.com/docs/notifier/node_rollbar/ for documentation on setting up Rollbar for node processes.
This library will initialize Rollbar
See https://rollbar.com/docs/notifier/rollbar.js/#quick-start-server for documentation on setting up Rollbar for node processes.
## Browser
For browser usage, this library expects Rollbar to be loaded via their quick-start script tag. This also allows Rollbar to capture any errors before the logger's initialization code, if that's important to you.
See https://rollbar.com/docs/notifier/rollbar.js/#quick-start for documentation on setting up Rollbar for browser applications
See https://rollbar.com/docs/notifier/rollbar.js/#quick-start-browser for documentation on setting up Rollbar for browser applications
# Development
View
@@ -77,7 +77,7 @@
"le_js": "git://github.com/nason/le_js.git#7a75be7c1dd2438e3f1183a68bd2162b80bc94d8",
"le_node": "^1.7.0",
"lodash": "^4.17.4",
"rollbar": "^0.6.3",
"rollbar": "2.2.9",
"uuid": "3.0.1"
},
"devDependencies": {
View
@@ -74,7 +74,11 @@ export default function NodeLogger(config = {}, logger) {
// Server-specific extras
this.requestLogger = createRequestLogger(this, serverConfig);
this.rollbarErrorMiddleware = Rollbar.errorHandler(serverConfig.rollbarToken);
const rollbar = new Rollbar({
accessToken: config.rollbarToken,
});
this.rollbarErrorMiddleware = rollbar.errorHandler(serverConfig.rollbarToken);
}
/* eslint-disable prefer-spread, prefer-rest-params */
Oops, something went wrong.

0 comments on commit efef298

Please sign in to comment.