Replace console with minilog

This commit is contained in:
Ray Schamp 2016-10-23 18:01:11 -04:00
parent f6c0064235
commit 73edb65c4d
5 changed files with 15 additions and 6 deletions

View file

@ -36,6 +36,7 @@
"json": "9.0.4", "json": "9.0.4",
"json-loader": "0.5.4", "json-loader": "0.5.4",
"lodash.defaultsdeep": "4.6.0", "lodash.defaultsdeep": "4.6.0",
"minilog": "3.0.1",
"promise": "7.1.1", "promise": "7.1.1",
"scratch-blocks": "latest", "scratch-blocks": "latest",
"scratch-render": "latest", "scratch-render": "latest",

View file

@ -1,3 +1,4 @@
var log = require('../util/log');
var Thread = require('./thread'); var Thread = require('./thread');
/** /**
@ -52,7 +53,7 @@ var execute = function (sequencer, thread) {
if (!opcode) { if (!opcode) {
console.warn('Could not get opcode for block: ' + currentBlockId); log.warn('Could not get opcode for block: ' + currentBlockId);
return; return;
} }
@ -110,7 +111,7 @@ var execute = function (sequencer, thread) {
handleReport(fields[fieldKey].value); handleReport(fields[fieldKey].value);
} }
} else { } else {
console.warn('Could not get implementation for opcode: ' + log.warn('Could not get implementation for opcode: ' +
opcode); opcode);
} }
thread.requestScriptGlowInFrame = true; thread.requestScriptGlowInFrame = true;
@ -234,7 +235,7 @@ var execute = function (sequencer, thread) {
}, function (rejectionReason) { }, function (rejectionReason) {
// Promise rejected: the primitive had some error. // Promise rejected: the primitive had some error.
// Log it and proceed. // Log it and proceed.
console.warn('Primitive rejected promise: ', rejectionReason); log.warn('Primitive rejected promise: ', rejectionReason);
thread.status = Thread.STATUS_RUNNING; thread.status = Thread.STATUS_RUNNING;
thread.popStack(); thread.popStack();
}); });

View file

@ -9,6 +9,7 @@ var Blocks = require('../engine/blocks');
var Clone = require('../sprites/clone'); var Clone = require('../sprites/clone');
var Sprite = require('../sprites/sprite'); var Sprite = require('../sprites/sprite');
var Color = require('../util/color.js'); var Color = require('../util/color.js');
var log = require('../util/log');
var uid = require('../util/uid'); var uid = require('../util/uid');
var specMap = require('./sb2specmap'); var specMap = require('./sb2specmap');
var Variable = require('../engine/variable'); var Variable = require('../engine/variable');
@ -251,7 +252,7 @@ var parseBlock = function (sb2block) {
var oldOpcode = sb2block[0]; var oldOpcode = sb2block[0];
// Convert the block using the specMap. See sb2specmap.js. // Convert the block using the specMap. See sb2specmap.js.
if (!oldOpcode || !specMap[oldOpcode]) { if (!oldOpcode || !specMap[oldOpcode]) {
console.warn('Couldn\'t find SB2 block: ', oldOpcode); log.warn('Couldn\'t find SB2 block: ', oldOpcode);
return; return;
} }
var blockMetadata = specMap[oldOpcode]; var blockMetadata = specMap[oldOpcode];

View file

@ -1,4 +1,6 @@
var util = require('util'); var util = require('util');
var log = require('../util/log');
var MathUtil = require('../util/math-util'); var MathUtil = require('../util/math-util');
var Target = require('../engine/target'); var Target = require('../engine/target');
@ -211,10 +213,10 @@ Clone.prototype.setSay = function (type, message) {
} }
// @todo: Render to stage. // @todo: Render to stage.
if (!type || !message) { if (!type || !message) {
console.log('Clearing say bubble'); log.info('Clearing say bubble');
return; return;
} }
console.log('Setting say bubble:', type, message); log.info('Setting say bubble:', type, message);
}; };
/** /**

4
src/util/log.js Normal file
View file

@ -0,0 +1,4 @@
var minilog = require('minilog');
minilog.enable();
module.exports = minilog('vm');