Skip to content

Commit

Permalink
fix(logs): removed extraneous logging statements
Browse files Browse the repository at this point in the history
  • Loading branch information
davidtucker committed May 9, 2021
1 parent c2b787d commit 201e586
Showing 1 changed file with 0 additions and 11 deletions.
11 changes: 0 additions & 11 deletions lib/logging.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,26 +59,18 @@ const generateLoggingObject = (logLevel, event, context, message) => {

// Add in flattened version of message parameter
if (message && typeof message === 'object') {
console.log('Message is object');
const flattenedMessage = flattenObject({ message });
console.log(`Flattened Object: ${JSON.stringify(flattenedMessage)}`);
output = { ...output, ...flattenedMessage };
} else if (typeof message === 'string') {
try {
console.log('');
const parsed = flattenObject({ message: JSON.parse(message) });
output = { ...output, ...parsed };
console.log('Treat message as JSON string');
} catch (_) {
console.log('Not object or JSON string - treat as regular string');
output.message = message;
}
} else {
console.log('Cannot log');
throw new Error('Can only log objects and strings');
}
console.log('Returning object');
console.log(`Output: ${JSON.stringify(output)}`);
return output;
};

Expand Down Expand Up @@ -123,11 +115,8 @@ export const getLogger = (event, context) => {
},
error: value => {
const level = getLoggingLevel();
console.log(`Log Level: ${level}`);
if (level <= LogLevel.ERROR) {
console.log(`Log Level Allowed - Error`);
console.error(generateLoggingObject(LogLevel.ERROR, event, context, value));
console.log(`Post logging`);
}
},
};
Expand Down

0 comments on commit 201e586

Please sign in to comment.