Skip to content

Commit

Permalink
fix(agent): debug log typeerror
Browse files Browse the repository at this point in the history
  • Loading branch information
dszakallas committed Mar 21, 2017
1 parent b80acae commit 3cdb41f
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 17 deletions.
2 changes: 1 addition & 1 deletion lib/agent/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ Agent.prototype.start = function () {
var self = this
this._api.getService(function (err, serviceKey) {
if (err) {
return debug(err.message)
return debug.error('start', 'Error starting service: ' + err.stack)
}
debug.info('start', 'ServiceKey is set to: ' + serviceKey)
self.serviceKey = serviceKey
Expand Down
9 changes: 4 additions & 5 deletions lib/agent/security/security.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,7 @@ Security.prototype.collectSnykFlags = function collectSnykFlags (callback) {
try {
patch = yaml.safeLoad(data).patch
} catch (ex) {
debug.error('collectSnykFlags', format('error collecting snyk flags: %s', ex))
debug.error(ex)
debug.error('collectSnykFlags', format('error collecting snyk flags: %s', ex.stack))
callback(null, [])
return
}
Expand All @@ -53,7 +52,7 @@ Security.prototype.collectSnykFlags = function collectSnykFlags (callback) {
if (_error) {
// ignore
debug.error('collectSnykFlags',
format('`npm ls <package_names> --long --parseable` returned error: %s', _error))
format('`npm ls <package_names> --long --parseable` returned error: %s', _error.stack))
}

var pkgs = stdout.split('\n')
Expand Down Expand Up @@ -140,13 +139,13 @@ Security.prototype.sendDependencies = function sendDependencies () {
var _this = this
this.collectDependencies(function (error, dependencies) {
if (error) {
debug.error('sendDependencies', format('error collecting dependencies: %s', error))
debug.error('sendDependencies', format('error collecting dependencies: %s', error.stack))
return
}

_this.collectSnykFlags(function (_error, flags) {
if (_error) {
debug.error('sendDependencies', format('error collecting snyk flags: %s', _error))
debug.error('sendDependencies', format('error collecting snyk flags: %s', _error.stack))
// send dependencies without patches
_this.collectorApi.sendDependencies(dependencies)
return
Expand Down
13 changes: 6 additions & 7 deletions lib/instrumentations/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,7 @@ function loadInstrumentationsForTarget (name, path) {
} catch (err) {
debug.warn('loadInstrumentationsForTarget',
format('instrumentation failed for `%s`. Could not load `%s`. Reason: %s',
name, path, err))
debug.warn(err)
name, path, err.stack))
}
if (!instrumentations) {
return
Expand Down Expand Up @@ -62,7 +61,7 @@ function instrumentModule (target, instrumentation, agent, load) {
} catch (err) {
debug.warn('instrumentModule', format('[Warning] cannot load `[%s] package.json`, ' +
'although it was requested by the instrumentation group. Instrumentation might not work properly. ' +
'Err: %s', target.name, err.message))
'Err: %s', target.name, err.stack))
}
}
if (instrumentation.pre) {
Expand All @@ -73,7 +72,7 @@ function instrumentModule (target, instrumentation, agent, load) {
} catch (err) {
debug.error('instrumentModule', format(
'[Error] Failed applying preload hook to module `[%s] %s`: %s. Instrumentation may not work properly',
target.name, instrumentation.path, err.message
target.name, instrumentation.path, err.stack
))
}
}
Expand All @@ -86,7 +85,7 @@ function instrumentModule (target, instrumentation, agent, load) {
} catch (err) {
debug.error('instrumentModule', format(
'Failed applying postload hook to module `[%s] %s`: %s. Instrumentation may not work properly',
target.name, instrumentation.path, err.message
target.name, instrumentation.path, err.stack
))
}
}
Expand All @@ -100,8 +99,8 @@ function loadTargetsEagerly (targets) {
try {
require(instrumentation.path)
} catch (err) {
debug.error('loadTargetsEagerly', format('Could not load module `[%s] %s`: `%s`',
target.name, instrumentation.path, err.message))
debug.error('loadTargetsEagerly', format('Could not load module `[%s] %s`: %s',
target.name, instrumentation.path, err.stack))
}
}
})
Expand Down
8 changes: 4 additions & 4 deletions lib/utils/configReader.js
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ ConfigReader.prototype._getEnvVarConfig = function () {
defaults(envVarConfig, { ignoreHeaders: ignoreHeaders })
} catch (err) {
debug.error('getEnvVarConfig',
format('[Error] Cannot parse TRACE_IGNORE_HEADERS. Error: %s', err.message))
format('[Error] Cannot parse TRACE_IGNORE_HEADERS. %s', err.stack))
}
}

Expand All @@ -92,7 +92,7 @@ ConfigReader.prototype._getEnvVarConfig = function () {
defaults(envVarConfig, { ignoreOutgoingHosts: ignoreOutgoingHosts })
} catch (err) {
debug.error('getEnvVarConfig',
format('Cannot parse TRACE_IGNORE_OUTGOING_HOSTS. Error: %s', err.message))
format('Cannot parse TRACE_IGNORE_OUTGOING_HOSTS. %s', err.stack))
}
}

Expand Down Expand Up @@ -183,9 +183,9 @@ ConfigReader.prototype._readProcFile = function (name) {
var procFileContent
try {
procFileContent = fs.readFileSync('/proc' + name, 'utf-8')
} catch (ex) {
} catch (err) {
debug.info('_readProcFile',
format('Cannot read procfile %s: Error: %s', name, ex))
format('Cannot read procfile %s: %s', name, err))
}
return procFileContent
}
Expand Down

0 comments on commit 3cdb41f

Please sign in to comment.