Build your personal knowledge base with Trilium Notes
TypeScript electronelectron-appknowledge-baseknowledge-graphknowledge-managementknowledge-management-graphlocal-firstnote-managmentnote-takernote-takingnotebooknotesnotes-apppersonal-knowledge-basepersonal-wikiscriptableself-hostedself-hostingwiki
improved logging
zadam3b58b83f8bb9
diff --git a/src/becca/becca_service.js b/src/becca/becca_service.jsindex b27e985f5e..f2cebbaaea 100644--- a/src/becca/becca_service.js+++ b/src/becca/becca_service.js@@ -67,7 +67,7 @@ function getNoteTitle(childNoteId, parentNoteId) {const parentNote = becca.notes[parentNoteId];if (!childNote) {- log.info(`Cannot find note in cache for noteId ${childNoteId}`);+ log.info(`Cannot find note in cache for noteId '${childNoteId}'`);return "[error fetching title]";}@@ -162,7 +162,7 @@ function getNotePath(noteId) {const note = becca.notes[noteId];if (!note) {- console.trace(`Cannot find note ${noteId} in cache.`);+ console.trace(`Cannot find note '${noteId}' in cache.`);return;}diff --git a/src/becca/entities/note.js b/src/becca/entities/note.jsindex 0192cff606..595e410522 100644--- a/src/becca/entities/note.js+++ b/src/becca/entities/note.js@@ -238,7 +238,7 @@ class Note extends AbstractEntity {setContent(content, ignoreMissingProtectedSession = false) {if (content === null || content === undefined) {- throw new Error(`Cannot set null content to note ${this.noteId}`);+ throw new Error(`Cannot set null content to note '${this.noteId}'`);}if (this.isStringNote()) {@@ -260,7 +260,7 @@ class Note extends AbstractEntity {pojo.content = protectedSessionService.encrypt(pojo.content);}else if (!ignoreMissingProtectedSession) {- throw new Error(`Cannot update content of noteId=${this.noteId} since we're out of protected session.`);+ throw new Error(`Cannot update content of noteId '${this.noteId}' since we're out of protected session.`);}}diff --git a/src/public/app/entities/note_short.js b/src/public/app/entities/note_short.jsindex 836755566c..2c403080d4 100644--- a/src/public/app/entities/note_short.js+++ b/src/public/app/entities/note_short.js@@ -124,7 +124,7 @@ class NoteShort {return JSON.parse(content);}catch (e) {- console.log(`Cannot parse content of note ${this.noteId}: `, e.message);+ console.log(`Cannot parse content of note '${this.noteId}': `, e.message);return null;}diff --git a/src/public/app/services/froca.js b/src/public/app/services/froca.jsindex abc59d7e0e..91af4f1b24 100644--- a/src/public/app/services/froca.js+++ b/src/public/app/services/froca.js@@ -179,7 +179,7 @@ class Froca {const searchResultNoteIds = await server.get('search-note/' + note.noteId);if (!Array.isArray(searchResultNoteIds)) {- throw new Error(`Search note ${note.noteId} failed: ${searchResultNoteIds}`);+ throw new Error(`Search note '${note.noteId}' failed: ${searchResultNoteIds}`);}// reset all the virtual branches from old search results@@ -254,7 +254,7 @@ class Froca {return null;}else if (!noteId) {- console.trace(`Falsy noteId ${noteId}, returning null.`);+ console.trace(`Falsy noteId '${noteId}', returning null.`);return null;}@@ -312,7 +312,7 @@ class Froca {if (!this.noteComplementPromises[noteId]) {this.noteComplementPromises[noteId] = server.get('notes/' + noteId).then(row => new NoteComplement(row))- .catch(e => console.error(`Cannot get note complement for note ${noteId}`));+ .catch(e => console.error(`Cannot get note complement for note '${noteId}'`));// we don't want to keep large payloads forever in memory so we clean that up quite quickly// this cache is more meant to share the data between different components within one business transaction (e.g. loading of the note into the tab context and all the components)diff --git a/src/routes/api/clipper.js b/src/routes/api/clipper.jsindex d777b9bb98..b8bb158e75 100644--- a/src/routes/api/clipper.js+++ b/src/routes/api/clipper.js@@ -138,7 +138,7 @@ function processContent(images, note, content) {value: imageNote.noteId}).save();- log.info(`Replacing ${imageId} with ${url} in note ${note.noteId}`);+ log.info(`Replacing '${imageId}' with '${url}' in note '${note.noteId}'`);rewrittenContent = utils.replaceAll(rewrittenContent, imageId, url);}diff --git a/src/routes/api/notes.js b/src/routes/api/notes.jsindex 82dbb813a6..5f334edc80 100644--- a/src/routes/api/notes.js+++ b/src/routes/api/notes.js@@ -96,7 +96,7 @@ function sortChildNotes(req) {const noteId = req.params.noteId;const {sortBy, sortDirection} = req.body;- log.info(`Sorting ${noteId} children with ${sortBy} ${sortDirection}`);+ log.info(`Sorting '${noteId}' children with ${sortBy} ${sortDirection}`);const reverse = sortDirection === 'desc';@@ -196,11 +196,11 @@ function changeTitle(req) {const note = becca.getNote(noteId);if (!note) {- return [404, `Note ${noteId} has not been found`];+ return [404, `Note '${noteId}' has not been found`];}if (!note.isContentAvailable()) {- return [400, `Note ${noteId} is not available for change`];+ return [400, `Note '${noteId}' is not available for change`];}const noteTitleChanged = note.title !== title;@@ -289,10 +289,10 @@ function uploadModifiedFile(req) {const note = becca.getNote(noteId);if (!note) {- return [404, `Note ${noteId} has not been found`];+ return [404, `Note '${noteId}' has not been found`];}- log.info(`Updating note ${noteId} with content from ${filePath}`);+ log.info(`Updating note '${noteId}' with content from ${filePath}`);noteRevisionService.createNoteRevision(note);diff --git a/src/services/notes.js b/src/services/notes.jsindex e69e603d46..86344061b1 100644--- a/src/services/notes.js+++ b/src/services/notes.js@@ -139,7 +139,7 @@ function createNewNote(params) {triggerNoteTitleChanged(note);triggerChildNoteCreated(note, parentNote);- log.info(`Created new note ${note.noteId}, branch ${branch.branchId} of type ${note.type}, mime ${note.mime}`);+ log.info(`Created new note '${note.noteId}', branch '${branch.branchId}' of type '${note.type}', mime '${note.mime}'`);return {note,@@ -285,10 +285,10 @@ async function downloadImage(noteId, imageUrl) {imageUrlToNoteIdMapping[imageUrl] = note.noteId;- log.info(`Download of ${imageUrl} succeeded and was saved as image note ${note.noteId}`);+ log.info(`Download of '${imageUrl}' succeeded and was saved as image note '${note.noteId}'`);}catch (e) {- log.error(`Download of ${imageUrl} for note ${noteId} failed with error: ${e.message} ${e.stack}`);+ log.error(`Download of '${imageUrl}' for note '${noteId}' failed with error: ${e.message} ${e.stack}`);}}@@ -373,7 +373,7 @@ function downloadImages(noteId, content) {const origNote = becca.getNote(noteId);if (!origNote) {- log.error(`Cannot find note ${noteId} to replace image link.`);+ log.error(`Cannot find note '${noteId}' to replace image link.`);return;}@@ -394,7 +394,7 @@ function downloadImages(noteId, content) {scanForLinks(origNote);- console.log(`Fixed the image links for note ${noteId} to the offline saved.`);+ console.log(`Fixed the image links for note '${noteId}' to the offline saved.`);}});}, 5000);@@ -491,7 +491,7 @@ function updateNote(noteId, noteUpdates) {const note = becca.getNote(noteId);if (!note.isContentAvailable()) {- throw new Error(`Note ${noteId} is not available for change!`);+ throw new Error(`Note '${noteId}' is not available for change!`);}saveNoteRevision(note);@@ -533,7 +533,7 @@ function undeleteNote(noteId, taskContext) {const note = sql.getRow("SELECT * FROM notes WHERE noteId = ?", [noteId]);if (!note.isDeleted) {- log.error(`Note ${noteId} is not deleted and thus cannot be undeleted.`);+ log.error(`Note '${noteId}' is not deleted and thus cannot be undeleted.`);return;}diff --git a/src/share/routes.js b/src/share/routes.jsindex 6090285973..cb9a9c8e34 100644--- a/src/share/routes.js+++ b/src/share/routes.js@@ -76,7 +76,7 @@ function register(router) {const note = shaca.getNote(noteId);if (!note) {- return res.status(404).send(`Note ${noteId} not found`);+ return res.status(404).send(`Note '${noteId}' not found`);}addNoIndexHeader(note, res);@@ -89,7 +89,7 @@ function register(router) {const note = shaca.getNote(noteId);if (!note) {- return res.status(404).send(`Note ${noteId} not found`);+ return res.status(404).send(`Note '${noteId}' not found`);}addNoIndexHeader(note, res);@@ -110,7 +110,7 @@ function register(router) {const image = shaca.getNote(req.params.noteId);if (!image) {- return res.status(404).send(`Note ${noteId} not found`);+ return res.status(404).send(`Note '${req.params.noteId}' not found`);}else if (image.type !== 'image') {return res.status(400).send("Requested note is not an image");@@ -129,7 +129,7 @@ function register(router) {const note = shaca.getNote(noteId);if (!note) {- return res.status(404).send(`Note ${noteId} not found`);+ return res.status(404).send(`Note '${noteId}' not found`);}addNoIndexHeader(note, res);