mirror of
				https://github.com/zadam/trilium.git
				synced 2025-10-31 10:26:08 +01:00 
			
		
		
		
	improved logging
This commit is contained in:
		| @@ -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; | ||||
|     } | ||||
|  | ||||
|   | ||||
| @@ -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.`); | ||||
|             } | ||||
|         } | ||||
|  | ||||
|   | ||||
| @@ -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; | ||||
|         } | ||||
|   | ||||
| @@ -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) | ||||
|   | ||||
| @@ -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); | ||||
|         } | ||||
|   | ||||
| @@ -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); | ||||
|  | ||||
|   | ||||
| @@ -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; | ||||
|     } | ||||
|  | ||||
|   | ||||
| @@ -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); | ||||
|   | ||||
		Reference in New Issue
	
	Block a user