Skip to content

Commit c23350a

Browse files
committed
replace console warn & error with ui.setDebugInfo
1 parent bc0973a commit c23350a

File tree

5 files changed

+11
-16
lines changed

5 files changed

+11
-16
lines changed

client/auth.ts

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -61,12 +61,12 @@ export class Authenticator {
6161
lightdm.respond(this._password);
6262
break;
6363
default:
64-
console.error(`Unknown lightDM prompt type: ${type}`);
64+
window.ui.setDebugInfo(`Unknown lightDM prompt type: ${type}`);
6565
break;
6666
}
6767
}
6868
catch (err) {
69-
console.error(err);
69+
window.ui.setDebugInfo(String(err));
7070
if (this._authEvents) {
7171
this._authEvents.errorMessage(String(err));
7272
}
@@ -84,18 +84,18 @@ export class Authenticator {
8484
}
8585
break;
8686
case LightDMMessageType.Error:
87-
console.error(`LightDM error message: ${message}`);
87+
window.ui.setDebugInfo(`LightDM error message: ${message}`);
8888
if (this._authEvents) {
8989
this._authEvents.errorMessage(message);
9090
}
9191
break;
9292
default:
93-
console.warn(`Unknown lightDM message type: ${type}, message: ${message}`);
93+
window.ui.setDebugInfo(`Unknown lightDM message type: ${type}, message: ${message}`);
9494
break;
9595
}
9696
}
9797
catch (err) {
98-
console.error(err);
98+
window.ui.setDebugInfo(String(err));
9999
if (this._authEvents) {
100100
this._authEvents.errorMessage(String(err));
101101
}
@@ -124,7 +124,7 @@ export class Authenticator {
124124
}
125125
}
126126
catch (err) {
127-
console.error(err);
127+
window.ui.setDebugInfo(String(err));
128128
if (this._authEvents) {
129129
this._authEvents.errorMessage(String(err));
130130
}
@@ -185,7 +185,7 @@ export class Authenticator {
185185
lightdm.authenticate(this._username); // provide username to skip the username prompt
186186
}
187187
catch (err) {
188-
console.error(err);
188+
window.ui.setDebugInfo(String(err));
189189
if (this._authEvents) {
190190
this._authEvents.errorMessage(String(err));
191191
}
@@ -203,12 +203,12 @@ export class Authenticator {
203203
this._password = password.substring(0, Authenticator.MAX_LEN_PASSWORD); // do not trim password as it could contain spaces at the beginning or end
204204

205205
if (this._authenticating || this._authenticated) {
206-
console.warn("Login() was called while already authenticating or authenticated. Stopping authentication.");
206+
window.ui.setDebugInfo("login() was called while already authenticating or authenticated");
207207
return;
208208
}
209209

210210
if (this._username === "" || this._password === "") {
211-
console.log("Login() was called while username or password is empty. Stopping authentication.");
211+
window.ui.setDebugInfo("login() was called while username or password is empty");
212212
return;
213213
}
214214

client/data.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,6 @@ export class Data {
172172
const data: DataJson = JSON.parse(req.responseText);
173173
console.log("Fetched data.json", data);
174174
if ("error" in data) {
175-
console.warn("data.json response contains an error", data);
176175
window.ui.setDebugInfo(`data.json response contains an error: ${data.error}`);
177176
return;
178177
}

client/ui.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,7 @@ export class UI {
9292
}
9393

9494
public setDebugInfo(info: string): void {
95+
console.log("Debug info:", info);
9596
this._infoBars.setDebugInfo(info);
9697
}
9798

client/uis/screens/examscreen.ts

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,6 @@ export class ExamModeUI extends UIScreen {
130130
const exams = window.data.dataJson?.exams.filter((exam) => examsToPopulate.some((examToPopulate) => exam.id === examToPopulate.id));
131131

132132
if (exams === undefined) {
133-
console.error('Failed to find exams in data.json');
134133
window.ui.setDebugInfo('Failed to find exams in data.json');
135134
return;
136135
}
@@ -200,10 +199,7 @@ export class ExamModeUI extends UIScreen {
200199

201200
protected _wigglePasswordInput(clearInput: boolean = true): void {
202201
// This should never happen. Display an error in the debug info bar.
203-
const message = `Failed to login with username "${ExamModeUI.EXAM_USERNAME}" and password "${ExamModeUI.EXAM_PASSWORD}" to start an exam session`;
204-
205-
window.ui.setDebugInfo(message);
206-
console.error(message);
202+
window.ui.setDebugInfo(`Failed to login with username "${ExamModeUI.EXAM_USERNAME}" and password "${ExamModeUI.EXAM_PASSWORD}" to start an exam session`);
207203
}
208204

209205
protected _getInputToFocusOn(): HTMLButtonElement | null {

client/uis/screens/lockscreen.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,6 @@ export class LockScreenUI extends UIScreen {
6868
}
6969
else {
7070
form.avatar.addEventListener('error', () => {
71-
console.warn(`Failed to load avatar for user ${this._activeSession.username}`);
7271
form.avatar.src = "assets/default-user.png"; // Load fallback image
7372
});
7473
if (await window.data.userImage.exists) {

0 commit comments

Comments
 (0)