Skip to content

Commit

Permalink
Make sure Logger exists
Browse files Browse the repository at this point in the history
  • Loading branch information
Colin-Fredericks committed Feb 22, 2024
1 parent baee3b2 commit 3b65cc6
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions hx.js
Original file line number Diff line number Diff line change
Expand Up @@ -161,9 +161,13 @@ var HXGlobalJS = function () {
logThatThing({ course_log_id: courseLogID });

// Listen for events that rewrite problem HTML.
Logger.listen('problem_check', null, (en, es) => onProblemRewrite(en, es));
Logger.listen('problem_show', null, (en, es) => onProblemRewrite(en, es));
Logger.listen('problem_reset', null, (en, es) => onProblemRewrite(en, es));
if( typeof Logger !== 'undefined' ){
Logger.listen('problem_check', null, (en, es) => onProblemRewrite(en, es));
Logger.listen('problem_show', null, (en, es) => onProblemRewrite(en, es));
Logger.listen('problem_reset', null, (en, es) => onProblemRewrite(en, es));
}else{
console.log('Logger is not available.');
}

/**************************************/
// Load outside scripts.
Expand Down Expand Up @@ -1401,7 +1405,11 @@ var HXGlobalJS = function () {
// Send logs both to the console and to the official edX logamajig.
function logThatThing(ThatThing) {
console.log(JSON.stringify(ThatThing));
Logger.log(courseLogID + '.hxjs', ThatThing);
if(typeof Logger !== 'undefined') {
Logger.log(courseLogID + '.hxjs', ThatThing);
}else{
console.log('Logger is not available.');
}
}

// Let's publish a few of these.
Expand Down

0 comments on commit 3b65cc6

Please sign in to comment.