Skip to content

Commit 0092a26

Browse files
refactor: add fallback logging for init routine
1 parent e040d05 commit 0092a26

1 file changed

Lines changed: 10 additions & 7 deletions

File tree

packages/superdoc/src/core/SuperDoc.js

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,9 @@ export class SuperDoc extends EventEmitter {
122122
/** @type {string} */
123123
version;
124124

125+
/** @type {Function} */
126+
logger = console.debug ? console.debug : console.log;
127+
125128
/** @type {User[]} */
126129
users;
127130

@@ -211,7 +214,7 @@ export class SuperDoc extends EventEmitter {
211214

212215
// @ts-ignore
213216
this.version = __APP_VERSION__;
214-
console.debug('🦋 [superdoc] Using SuperDoc version:', this.version);
217+
this.log('🦋 [superdoc] Using SuperDoc version:', this.version);
215218

216219
this.superdocId = config.superdocId || uuidv4();
217220
this.colors = this.config.colors;
@@ -479,7 +482,7 @@ export class SuperDoc extends EventEmitter {
479482
}
480483

481484
log(...args) {
482-
console.debug('🦋 🦸‍♀️ [superdoc]', ...args);
485+
this.logger('🦋 🦸‍♀️ [superdoc]', ...args);
483486
}
484487

485488
/**
@@ -558,7 +561,7 @@ export class SuperDoc extends EventEmitter {
558561
*/
559562
addCommentsList(element) {
560563
if (!this.config?.modules?.comments || this.config.role === 'viewer') return;
561-
console.debug('🦋 [superdoc] Adding comments list to:', element);
564+
this.log('🦋 [superdoc] Adding comments list to:', element);
562565
if (element) this.config.modules.comments.element = element;
563566
this.commentsList = new SuperComments(this.config.modules?.comments, this);
564567
if (this.config.onCommentsListChange) this.config.onCommentsListChange({ isRendered: true });
@@ -718,7 +721,7 @@ export class SuperDoc extends EventEmitter {
718721
lockSuperdoc(isLocked = false, lockedBy) {
719722
this.isLocked = isLocked;
720723
this.lockedBy = lockedBy;
721-
console.debug('🦋 [superdoc] Locking superdoc:', isLocked, lockedBy, '\n\n\n');
724+
this.log('🦋 [superdoc] Locking superdoc:', isLocked, lockedBy, '\n\n\n');
722725
this.emit('locked', { isLocked, lockedBy });
723726
}
724727

@@ -801,7 +804,7 @@ export class SuperDoc extends EventEmitter {
801804
* @returns {Promise<void>} Resolves when all documents have saved
802805
*/
803806
async #triggerCollaborationSaves() {
804-
console.debug('🦋 [superdoc] Triggering collaboration saves');
807+
this.log('🦋 [superdoc] Triggering collaboration saves');
805808
return new Promise((resolve, reject) => {
806809
this.superdocStore.documents.forEach((doc) => {
807810
this.pendingCollaborationSaves = 0;
@@ -832,9 +835,9 @@ export class SuperDoc extends EventEmitter {
832835
// this.exportEditorsToDOCX(),
833836
];
834837

835-
console.debug('🦋 [superdoc] Saving superdoc');
838+
this.log('🦋 [superdoc] Saving superdoc');
836839
const result = await Promise.all(savePromises);
837-
console.debug('🦋 [superdoc] Save complete:', result);
840+
this.log('🦋 [superdoc] Save complete:', result);
838841
return result;
839842
}
840843

0 commit comments

Comments
 (0)