mirror of
https://github.com/HifiExperiments/overte.git
synced 2025-05-19 06:40:01 +02:00
Tidy up logging
This commit is contained in:
parent
b58cac1c56
commit
20c7e17fb6
4 changed files with 41 additions and 33 deletions
|
@ -10,7 +10,7 @@
|
||||||
|
|
||||||
/* global CreatePalette */
|
/* global CreatePalette */
|
||||||
|
|
||||||
CreatePalette = function (side, leftInputs, rightInputs, uiCommandCallback) {
|
CreatePalette = function (App, side, leftInputs, rightInputs, uiCommandCallback) {
|
||||||
// Tool menu displayed on top of forearm.
|
// Tool menu displayed on top of forearm.
|
||||||
|
|
||||||
"use strict";
|
"use strict";
|
||||||
|
@ -250,7 +250,7 @@ CreatePalette = function (side, leftInputs, rightInputs, uiCommandCallback) {
|
||||||
if (handJointIndex === NONE) {
|
if (handJointIndex === NONE) {
|
||||||
// Don't display if joint isn't available (yet) to attach to.
|
// Don't display if joint isn't available (yet) to attach to.
|
||||||
// User can clear this condition by toggling the app off and back on once avatar finishes loading.
|
// User can clear this condition by toggling the app off and back on once avatar finishes loading.
|
||||||
// TODO: Log error.
|
App.log(side, "ERROR: CreatePalette: Hand joint index isn't available!");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -10,7 +10,7 @@
|
||||||
|
|
||||||
/* global ToolIcon */
|
/* global ToolIcon */
|
||||||
|
|
||||||
ToolIcon = function (side) {
|
ToolIcon = function (App, side) {
|
||||||
// Tool icon displayed on non-dominant hand.
|
// Tool icon displayed on non-dominant hand.
|
||||||
|
|
||||||
"use strict";
|
"use strict";
|
||||||
|
@ -80,7 +80,7 @@ ToolIcon = function (side) {
|
||||||
if (handJointIndex === -1) {
|
if (handJointIndex === -1) {
|
||||||
// Don't display if joint isn't available (yet) to attach to.
|
// Don't display if joint isn't available (yet) to attach to.
|
||||||
// User can clear this condition by toggling the app off and back on once avatar finishes loading.
|
// User can clear this condition by toggling the app off and back on once avatar finishes loading.
|
||||||
// TODO: Log error.
|
App.log(side, "ERROR: ToolIcon: Hand joint index isn't available!");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -10,7 +10,7 @@
|
||||||
|
|
||||||
/* global ToolMenu */
|
/* global ToolMenu */
|
||||||
|
|
||||||
ToolMenu = function (side, leftInputs, rightInputs, uiCommandCallback) {
|
ToolMenu = function (App, side, leftInputs, rightInputs, uiCommandCallback) {
|
||||||
// Tool menu displayed on top of forearm.
|
// Tool menu displayed on top of forearm.
|
||||||
|
|
||||||
"use strict";
|
"use strict";
|
||||||
|
@ -840,7 +840,7 @@ ToolMenu = function (side, leftInputs, rightInputs, uiCommandCallback) {
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
// TODO: Log error.
|
App.log(side, "ERROR: ToolMenu: Unexpected command! " + command);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -858,7 +858,7 @@ ToolMenu = function (side, leftInputs, rightInputs, uiCommandCallback) {
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
// TODO: Log error.
|
App.log(side, "ERROR: ToolMenu: Unexpected command! " + command);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1103,7 +1103,7 @@ ToolMenu = function (side, leftInputs, rightInputs, uiCommandCallback) {
|
||||||
if (handJointIndex === NONE) {
|
if (handJointIndex === NONE) {
|
||||||
// Don't display if joint isn't available (yet) to attach to.
|
// Don't display if joint isn't available (yet) to attach to.
|
||||||
// User can clear this condition by toggling the app off and back on once avatar finishes loading.
|
// User can clear this condition by toggling the app off and back on once avatar finishes loading.
|
||||||
// TODO: Log error.
|
App.log(side, "ERROR: ToolMenu: Hand joint index isn't available!");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -34,6 +34,7 @@
|
||||||
colorToolColor = { red: 128, green: 128, blue: 128 },
|
colorToolColor = { red: 128, green: 128, blue: 128 },
|
||||||
|
|
||||||
// Primary objects
|
// Primary objects
|
||||||
|
App,
|
||||||
Inputs,
|
Inputs,
|
||||||
inputs = [],
|
inputs = [],
|
||||||
UI,
|
UI,
|
||||||
|
@ -79,21 +80,22 @@
|
||||||
Script.include("./modules/toolMenu.js");
|
Script.include("./modules/toolMenu.js");
|
||||||
|
|
||||||
|
|
||||||
function log(message) {
|
function log(side, message) {
|
||||||
print(APP_NAME + ": " + message);
|
// Optional parameter: side.
|
||||||
|
var hand = "",
|
||||||
|
HAND_LETTERS = ["L", "R"];
|
||||||
|
if (side === 0 || side === 1) {
|
||||||
|
hand = HAND_LETTERS[side] + " ";
|
||||||
|
} else {
|
||||||
|
message = side;
|
||||||
|
}
|
||||||
|
print(APP_NAME + ": " + hand + message);
|
||||||
}
|
}
|
||||||
|
|
||||||
function debug(side, message) {
|
function debug(side, message) {
|
||||||
// Optional parameter: side.
|
// Optional parameter: side.
|
||||||
var hand = "",
|
|
||||||
HAND_LETTERS = ["L", "R"];
|
|
||||||
if (DEBUG) {
|
if (DEBUG) {
|
||||||
if (side === 0 || side === 1) {
|
log(side, message);
|
||||||
hand = HAND_LETTERS[side] + " ";
|
|
||||||
} else {
|
|
||||||
message = side;
|
|
||||||
}
|
|
||||||
log(hand + message);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -101,6 +103,12 @@
|
||||||
return (hand + 1) % 2;
|
return (hand + 1) % 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
App = {
|
||||||
|
log: log,
|
||||||
|
debug: debug,
|
||||||
|
DEBUG: DEBUG
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
Inputs = function (side) {
|
Inputs = function (side) {
|
||||||
// A hand plus a laser.
|
// A hand plus a laser.
|
||||||
|
@ -180,7 +188,7 @@
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
UI = function (side, leftInputs, rightInputs, uiCommandCallback) {
|
UI = function (App, side, leftInputs, rightInputs, uiCommandCallback) {
|
||||||
// Tool menu and Create palette.
|
// Tool menu and Create palette.
|
||||||
|
|
||||||
var // Primary objects.
|
var // Primary objects.
|
||||||
|
@ -197,9 +205,9 @@
|
||||||
return new UI();
|
return new UI();
|
||||||
}
|
}
|
||||||
|
|
||||||
toolIcon = new ToolIcon(otherHand(side));
|
toolIcon = new ToolIcon(App, otherHand(side));
|
||||||
toolMenu = new ToolMenu(side, leftInputs, rightInputs, uiCommandCallback);
|
toolMenu = new ToolMenu(App, side, leftInputs, rightInputs, uiCommandCallback);
|
||||||
createPalette = new CreatePalette(side, leftInputs, rightInputs, uiCommandCallback);
|
createPalette = new CreatePalette(App, side, leftInputs, rightInputs, uiCommandCallback);
|
||||||
|
|
||||||
getIntersection = side === LEFT_HAND ? rightInputs.intersection : leftInputs.intersection;
|
getIntersection = side === LEFT_HAND ? rightInputs.intersection : leftInputs.intersection;
|
||||||
|
|
||||||
|
@ -807,8 +815,8 @@
|
||||||
STATE_MACHINE[EDITOR_STATE_STRINGS[editorState]].exit();
|
STATE_MACHINE[EDITOR_STATE_STRINGS[editorState]].exit();
|
||||||
STATE_MACHINE[EDITOR_STATE_STRINGS[state]].enter();
|
STATE_MACHINE[EDITOR_STATE_STRINGS[state]].enter();
|
||||||
editorState = state;
|
editorState = state;
|
||||||
} else if (DEBUG) {
|
} else {
|
||||||
log("ERROR: Null state transition: " + state + "!");
|
log(side, "ERROR: Editor: Null state transition: " + state + "!");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -897,7 +905,7 @@
|
||||||
setState(EDITOR_GRABBING);
|
setState(EDITOR_GRABBING);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
debug(side, "ERROR: Unexpected condition in EDITOR_SEARCHING!");
|
log(side, "ERROR: Editor: Unexpected condition in EDITOR_SEARCHING!");
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case EDITOR_HIGHLIGHTING:
|
case EDITOR_HIGHLIGHTING:
|
||||||
|
@ -938,7 +946,7 @@
|
||||||
if (toolSelected !== TOOL_SCALE) {
|
if (toolSelected !== TOOL_SCALE) {
|
||||||
setState(EDITOR_DIRECT_SCALING);
|
setState(EDITOR_DIRECT_SCALING);
|
||||||
} else {
|
} else {
|
||||||
debug(side, "ERROR: Unexpected condition in EDITOR_HIGHLIGHTING! A");
|
log(side, "ERROR: Editor: Unexpected condition A in EDITOR_HIGHLIGHTING!");
|
||||||
}
|
}
|
||||||
} else if (toolSelected === TOOL_CLONE) {
|
} else if (toolSelected === TOOL_CLONE) {
|
||||||
setState(EDITOR_CLONING);
|
setState(EDITOR_CLONING);
|
||||||
|
@ -967,7 +975,7 @@
|
||||||
} else if (!intersection.entityID || !intersection.editableEntity) {
|
} else if (!intersection.entityID || !intersection.editableEntity) {
|
||||||
setState(EDITOR_SEARCHING);
|
setState(EDITOR_SEARCHING);
|
||||||
} else {
|
} else {
|
||||||
debug(side, "ERROR: Unexpected condition in EDITOR_HIGHLIGHTING! B");
|
log(side, "ERROR: Editor: Unexpected condition B in EDITOR_HIGHLIGHTING!");
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case EDITOR_GRABBING:
|
case EDITOR_GRABBING:
|
||||||
|
@ -996,7 +1004,7 @@
|
||||||
setState(EDITOR_SEARCHING);
|
setState(EDITOR_SEARCHING);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
debug(side, "ERROR: Unexpected condition in EDITOR_GRABBING!");
|
log(side, "ERROR: Editor: Unexpected condition in EDITOR_GRABBING!");
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case EDITOR_DIRECT_SCALING:
|
case EDITOR_DIRECT_SCALING:
|
||||||
|
@ -1023,7 +1031,7 @@
|
||||||
// Grab highlightEntityID that was scaling and has already been set.
|
// Grab highlightEntityID that was scaling and has already been set.
|
||||||
setState(EDITOR_GRABBING);
|
setState(EDITOR_GRABBING);
|
||||||
} else {
|
} else {
|
||||||
debug(side, "ERROR: Unexpected condition in EDITOR_DIRECT_SCALING!");
|
log(side, "ERROR: Editor: Unexpected condition in EDITOR_DIRECT_SCALING!");
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case EDITOR_HANDLE_SCALING:
|
case EDITOR_HANDLE_SCALING:
|
||||||
|
@ -1049,7 +1057,7 @@
|
||||||
// Grab highlightEntityID that was scaling and has already been set.
|
// Grab highlightEntityID that was scaling and has already been set.
|
||||||
setState(EDITOR_GRABBING);
|
setState(EDITOR_GRABBING);
|
||||||
} else {
|
} else {
|
||||||
debug(side, "ERROR: Unexpected condition in EDITOR_HANDLE_SCALING!");
|
log(side, "ERROR: Editor: Unexpected condition in EDITOR_HANDLE_SCALING!");
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case EDITOR_CLONING:
|
case EDITOR_CLONING:
|
||||||
|
@ -1066,7 +1074,7 @@
|
||||||
setState(EDITOR_SEARCHING);
|
setState(EDITOR_SEARCHING);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
debug(side, "ERROR: Unexpected condition in EDITOR_CLONING!");
|
log(side, "ERROR: Editor: Unexpected condition in EDITOR_CLONING!");
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case EDITOR_GROUPING:
|
case EDITOR_GROUPING:
|
||||||
|
@ -1353,7 +1361,7 @@
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
debug("ERROR: Unexpected command in onUICommand()! " + command);
|
log("ERROR: Unexpected command in onUICommand(): " + command);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1432,7 +1440,7 @@
|
||||||
inputs[RIGHT_HAND] = new Inputs(RIGHT_HAND);
|
inputs[RIGHT_HAND] = new Inputs(RIGHT_HAND);
|
||||||
|
|
||||||
// UI object.
|
// UI object.
|
||||||
ui = new UI(otherHand(dominantHand), inputs[LEFT_HAND], inputs[RIGHT_HAND], onUICommand);
|
ui = new UI(App, otherHand(dominantHand), inputs[LEFT_HAND], inputs[RIGHT_HAND], onUICommand);
|
||||||
|
|
||||||
// Editor objects.
|
// Editor objects.
|
||||||
editors[LEFT_HAND] = new Editor(LEFT_HAND);
|
editors[LEFT_HAND] = new Editor(LEFT_HAND);
|
||||||
|
|
Loading…
Reference in a new issue