Logger: rename 'error' => 'exception' to avoid name clashing in E/S

This commit is contained in:
Daniel García Aubert 2020-07-21 17:53:46 +02:00
parent 3102d895f2
commit b9198b59a1
13 changed files with 15 additions and 15 deletions

View File

@ -236,7 +236,7 @@ function createTemplateMaps ({ redisPool, surrogateKeysCache, logger }) {
const startTime = Date.now();
surrogateKeysCache.invalidate(new NamedMapsCacheEntry(user, templateName), (err) => {
if (err) {
return logger.error({ error: err, 'cdb-user': user, template_id: templateName }, 'Named map invalidation failed');
return logger.error({ exception: err, 'cdb-user': user, template_id: templateName }, 'Named map invalidation failed');
}
logger.info({ 'cdb-user': user, template_id: templateName, duration: (Date.now() - startTime) / 1000 }, 'Named map invalidation success');

View File

@ -343,7 +343,7 @@ function incrementMapViews ({ metadataBackend }) {
mapConfigProvider.getMapConfig((err, mapConfig) => {
if (err) {
logger.warn({ error: err }, 'Failed to increment mapview count');
logger.warn({ exception: err }, 'Failed to increment mapview count');
return next();
}
@ -353,7 +353,7 @@ function incrementMapViews ({ metadataBackend }) {
metadataBackend.incMapviewCount(user, statTag, (err) => {
if (err) {
logger.warn({ error: err }, 'Failed to increment mapview count');
logger.warn({ exception: err }, 'Failed to increment mapview count');
}
next();

View File

@ -10,7 +10,7 @@ module.exports = function setCacheChannelHeader () {
mapConfigProvider.getAffectedTables((err, affectedTables) => {
if (err) {
logger.warn({ error: err }, 'Error generating Cache Channel Header');
logger.warn({ exception: err }, 'Error generating Cache Channel Header');
return next();
}

View File

@ -44,7 +44,7 @@ module.exports = function setCacheControlHeader ({
mapConfigProvider.getAffectedTables((err, affectedTables) => {
if (err) {
logger.warn({ error: err }, 'Error generating Cache Control Header');
logger.warn({ exception: err }, 'Error generating Cache Control Header');
return next();
}

View File

@ -7,7 +7,7 @@ module.exports = function errorMiddleware (/* options */) {
const { logger } = res.locals;
const errors = populateLimitErrors(Array.isArray(err) ? err : [err]);
errors.forEach((err) => logger.error({ error: err }, 'Error while handling the request'));
errors.forEach((err) => logger.error({ exception: err }, 'Error while handling the request'));
setCommonHeaders(req, res, () => {
const errorResponseBody = {

View File

@ -7,7 +7,7 @@ module.exports = function incrementMapViewCount (metadataBackend) {
metadataBackend.incMapviewCount(user, statTag, (err) => {
if (err) {
logger.warn({ error: err }, 'Failed to increment mapview count');
logger.warn({ exception: err }, 'Failed to increment mapview count');
}
next();

View File

@ -21,7 +21,7 @@ module.exports = function setLastModifiedHeader () {
mapConfigProvider.getAffectedTables((err, affectedTables) => {
if (err) {
logger.warn({ error: err }, 'Error generating Last Modified Header');
logger.warn({ exception: err }, 'Error generating Last Modified Header');
return next();
}

View File

@ -23,7 +23,7 @@ module.exports = function metrics ({ enabled, tags, metricsBackend }) {
const { event, attributes } = getEventData(req, res, tags);
metricsBackend.send(event, attributes)
.catch((err) => logger.error({ error: err, event }, 'Failed to publish event'));
.catch((err) => logger.error({ exception: err, event }, 'Failed to publish event'));
});
return next();

View File

@ -17,7 +17,7 @@ module.exports = function setSurrogateKeyHeader ({ surrogateKeysCache }) {
mapConfigProvider.getAffectedTables((err, affectedTables) => {
if (err) {
logger.warn({ error: err }, 'Error generating Surrogate Key Header');
logger.warn({ exception: err }, 'Error generating Surrogate Key Header');
return next();
}

View File

@ -105,7 +105,7 @@ TurboCartoAdapter.prototype._parseCartoCss = function (username, params, layer,
context: err.context
};
return callback(null, { error: error });
return callback(null, { exception: error });
}
// Try to continue in the rest of the cases

View File

@ -39,7 +39,7 @@ module.exports = function setCommonHeaders (req, res, callback) {
getStatTag({ res }, (err, statTag) => {
if (err) {
logger.warn({ error: err }, 'Error generating Stat Tag header');
logger.warn({ exception: err }, 'Error generating Stat Tag header');
}
if (statTag) {
@ -99,7 +99,7 @@ function getTemplateHash ({ res }) {
try {
templateHash = res.locals.mapConfigProvider.getTemplateHash().substring(0, 8);
} catch (err) {
logger.warn({ error: err }, 'Error generating Stat Tag header');
logger.warn({ exception: err }, 'Error generating Stat Tag header');
}
return templateHash;

View File

@ -29,7 +29,7 @@ module.exports = class Logger {
serializers: {
client_request: requestSerializer,
server_response: responseSerializer,
error: errorSerializer
exception: errorSerializer
}
};
const dest = pino.destination({ sync: false }); // stdout

2
package-lock.json generated
View File

@ -814,7 +814,7 @@
"integrity": "sha1-MvxLn82vhF/N9+c7uXysImHwqwo="
},
"camshaft": {
"version": "github:cartodb/camshaft#a2bc005a0010f174a68d49d7c2f35020404db69e",
"version": "github:cartodb/camshaft#0fde77351f4efef767e758aa1160e22d2ef6e65f",
"from": "github:cartodb/camshaft#feature/ch91877/remove-log-aggregation-in-metro",
"requires": {
"async": "^1.5.2",