diff --git a/package.json b/package.json index 948e7130a..e1a23179b 100644 --- a/package.json +++ b/package.json @@ -36,6 +36,7 @@ "json": "9.0.4", "json-loader": "0.5.4", "lodash.defaultsdeep": "4.6.0", + "minilog": "3.0.1", "promise": "7.1.1", "scratch-blocks": "latest", "scratch-render": "latest", diff --git a/src/engine/execute.js b/src/engine/execute.js index 9017ff240..847fac0ff 100644 --- a/src/engine/execute.js +++ b/src/engine/execute.js @@ -1,3 +1,4 @@ +var log = require('../util/log'); var Thread = require('./thread'); /** @@ -52,7 +53,7 @@ var execute = function (sequencer, thread) { if (!opcode) { - console.warn('Could not get opcode for block: ' + currentBlockId); + log.warn('Could not get opcode for block: ' + currentBlockId); return; } @@ -110,7 +111,7 @@ var execute = function (sequencer, thread) { handleReport(fields[fieldKey].value); } } else { - console.warn('Could not get implementation for opcode: ' + + log.warn('Could not get implementation for opcode: ' + opcode); } thread.requestScriptGlowInFrame = true; @@ -234,7 +235,7 @@ var execute = function (sequencer, thread) { }, function (rejectionReason) { // Promise rejected: the primitive had some error. // Log it and proceed. - console.warn('Primitive rejected promise: ', rejectionReason); + log.warn('Primitive rejected promise: ', rejectionReason); thread.status = Thread.STATUS_RUNNING; thread.popStack(); }); diff --git a/src/import/sb2import.js b/src/import/sb2import.js index a2526c3d0..b09c7c536 100644 --- a/src/import/sb2import.js +++ b/src/import/sb2import.js @@ -9,6 +9,7 @@ var Blocks = require('../engine/blocks'); var Clone = require('../sprites/clone'); var Sprite = require('../sprites/sprite'); var Color = require('../util/color.js'); +var log = require('../util/log'); var uid = require('../util/uid'); var specMap = require('./sb2specmap'); var Variable = require('../engine/variable'); @@ -251,7 +252,7 @@ var parseBlock = function (sb2block) { var oldOpcode = sb2block[0]; // Convert the block using the specMap. See sb2specmap.js. if (!oldOpcode || !specMap[oldOpcode]) { - console.warn('Couldn\'t find SB2 block: ', oldOpcode); + log.warn('Couldn\'t find SB2 block: ', oldOpcode); return; } var blockMetadata = specMap[oldOpcode]; diff --git a/src/sprites/clone.js b/src/sprites/clone.js index c5e8e0ca6..e49bbf82d 100644 --- a/src/sprites/clone.js +++ b/src/sprites/clone.js @@ -1,4 +1,6 @@ var util = require('util'); + +var log = require('../util/log'); var MathUtil = require('../util/math-util'); var Target = require('../engine/target'); @@ -211,10 +213,10 @@ Clone.prototype.setSay = function (type, message) { } // @todo: Render to stage. if (!type || !message) { - console.log('Clearing say bubble'); + log.info('Clearing say bubble'); return; } - console.log('Setting say bubble:', type, message); + log.info('Setting say bubble:', type, message); }; /** diff --git a/src/util/log.js b/src/util/log.js new file mode 100644 index 000000000..28e596a12 --- /dev/null +++ b/src/util/log.js @@ -0,0 +1,4 @@ +var minilog = require('minilog'); +minilog.enable(); + +module.exports = minilog('vm');