From 1732cda1e607e7ac38ddf2f597580ca108a17eaf Mon Sep 17 00:00:00 2001 From: John Cowen Date: Tue, 15 Sep 2020 18:45:22 +0100 Subject: [PATCH] ui: Use runInDebug to add error logging to logger service (#8658) --- ui-v2/app/services/logger.js | 12 +++++++++++- ui-v2/app/services/state.js | 2 +- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/ui-v2/app/services/logger.js b/ui-v2/app/services/logger.js index c8e80171bf..e61252afee 100644 --- a/ui-v2/app/services/logger.js +++ b/ui-v2/app/services/logger.js @@ -1,5 +1,15 @@ import Service from '@ember/service'; +import { runInDebug } from '@ember/debug'; export default Service.extend({ - execute: function(obj) {}, + execute: function(obj) { + runInDebug(() => { + obj = typeof obj.error !== 'undefined' ? obj.error : obj; + if (obj instanceof Error) { + console.error(obj); // eslint-disable-line no-console + } else { + console.log(obj); // eslint-disable-line no-console + } + }); + }, }); diff --git a/ui-v2/app/services/state.js b/ui-v2/app/services/state.js index 598ae37f0e..efb9cd88eb 100644 --- a/ui-v2/app/services/state.js +++ b/ui-v2/app/services/state.js @@ -7,7 +7,7 @@ export default Service.extend({ logger: service('logger'), // @xstate/fsm log: function(chart, state) { - this.logger.execute(`${chart.id} > ${state.value}`); + // this.logger.execute(`${chart.id} > ${state.value}`); }, addGuards: function(chart, options) { this.guards(chart).forEach(function([path, name]) {