Skip to content

Commit

Permalink
Limit console logging
Browse files Browse the repository at this point in the history
  • Loading branch information
wagenet committed Mar 8, 2021
1 parent 65bc0bb commit f5c7183
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion vendor/ember-cli-deprecation-workflow/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
self.deprecationWorkflow.deprecationLog = {
messages: { }
};
self.deprecationWorkflow.logCounts = {};

function detectWorkflow(config, message, options) {
if (!config || !config.workflow) {
Expand Down Expand Up @@ -43,7 +44,17 @@
// no-op
break;
case 'log':
console.warn('DEPRECATION: ' + message);
var key = options && options.id || message;
let count = self.deprecationWorkflow.logCounts[key] || 0;
self.deprecationWorkflow.logCounts[key] = count + 1;

if (count <= 100) {
console.warn('DEPRECATION: ' + message);
if (count === 100) {
console.warn('To avoid console overflow, this deprecation will not be logged anymore in this run.');
}
}

break;
case 'throw':
throw new Error(message);
Expand Down

0 comments on commit f5c7183

Please sign in to comment.