Skip to content

Commit

Permalink
Use client LE.createLogStream for better compatibility. Closes #2.
Browse files Browse the repository at this point in the history
`LE.init` is deprecated and causing test failures in IE < 10.
  • Loading branch information
Mike Nason committed Oct 24, 2016
1 parent 55ca75e commit 0ed3b5a
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 13 deletions.
5 changes: 4 additions & 1 deletion src/client.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,10 @@ function getStreams(config) {
streams.push({
name: 'logentries',
level: config.level,
stream: new ClientLogentriesLogger({ token: config.logentriesToken }),
stream: new ClientLogentriesLogger({
name: config.name,
token: config.logentriesToken
}),
type: 'raw'
});
}
Expand Down
11 changes: 6 additions & 5 deletions src/util/client/logentriesLogger.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,9 @@ import LE from 'le_js';
* @param {String} options.token
* @param {String} options.level
*/
export default function ClientLogentriesLogger({ token }) {
LE.init({
export default function ClientLogentriesLogger({ name, token }) {
this.logentries = LE.createLogStream({
name,
token,
no_format: true,
page_info: 'per-page'
Expand All @@ -22,9 +23,9 @@ export default function ClientLogentriesLogger({ token }) {
*/
ClientLogentriesLogger.prototype.write = function (data = {}) {
const level = bunyan.nameFromLevel[data.level];
if (isFunction(LE[level])) {
LE[level](data);
if (isFunction(this.logentries[level])) {
this.logentries[level](data);
} else {
LE.log(data);
this.logentries.log(data);
}
};
12 changes: 5 additions & 7 deletions src/util/common/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,9 @@ export const DEFAULT_CONFIG = Object.freeze({
* @returns {Object} runtimeConfig
*/
export function assembleConfig(config, getStreamsForRuntime) {
return Object.assign({},
DEFAULT_CONFIG,
config,
{
streams: getStreamsForRuntime(config)
}
);
const baseConfig = Object.assign({}, DEFAULT_CONFIG, config);

return Object.assign(baseConfig, {
streams: getStreamsForRuntime(baseConfig)
});
}
1 change: 1 addition & 0 deletions test/specs/requestLogger.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ if (typeof document === 'undefined') {
cb = sinon.stub();

logger = new Logger({
stdout: false,
streams: [
{ type: 'raw', stream: new TestLogger({ cb }) }
]
Expand Down

0 comments on commit 0ed3b5a

Please sign in to comment.