Add missing logging context at various places

Our custom logger supports providing the name of the function that
calls the logger, this commit adds this context string where it
was previously missing.

Signed-off-by: David Mehren <git@herrmehren.de>
This commit is contained in:
David Mehren 2021-02-05 22:30:22 +01:00
parent 0dbcc9a653
commit 99ddee7815
No known key found for this signature in database
GPG key ID: 185982BA4C42B7C3
3 changed files with 11 additions and 7 deletions

View file

@ -54,7 +54,7 @@ export class NotesController {
@MarkdownBody() text: string,
): Promise<NoteDto> {
// ToDo: provide user for createNoteDto
this.logger.debug('Got raw markdown:\n' + text);
this.logger.debug('Got raw markdown:\n' + text, 'createNote');
return this.noteService.toNoteDto(
await this.noteService.createNote(text, undefined, req.user),
);
@ -84,7 +84,7 @@ export class NotesController {
@MarkdownBody() text: string,
): Promise<NoteDto> {
// ToDo: check if user is allowed to view this note
this.logger.debug('Got raw markdown:\n' + text);
this.logger.debug('Got raw markdown:\n' + text, 'createNamedNote');
return this.noteService.toNoteDto(
await this.noteService.createNote(text, noteAlias, req.user),
);
@ -97,7 +97,7 @@ export class NotesController {
@Param('noteIdOrAlias') noteIdOrAlias: string,
): Promise<void> {
// ToDo: check if user is allowed to delete this note
this.logger.debug('Deleting note: ' + noteIdOrAlias);
this.logger.debug('Deleting note: ' + noteIdOrAlias, 'deleteNote');
try {
await this.noteService.deleteNoteByIdOrAlias(noteIdOrAlias);
} catch (e) {
@ -106,7 +106,7 @@ export class NotesController {
}
throw e;
}
this.logger.debug('Successfully deleted ' + noteIdOrAlias);
this.logger.debug('Successfully deleted ' + noteIdOrAlias, 'deleteNote');
return;
}
@ -118,7 +118,7 @@ export class NotesController {
@MarkdownBody() text: string,
): Promise<NoteDto> {
// ToDo: check if user is allowed to change this note
this.logger.debug('Got raw markdown:\n' + text);
this.logger.debug('Got raw markdown:\n' + text, 'updateNote');
try {
return this.noteService.toNoteDto(
await this.noteService.updateNoteByIdOrAlias(noteIdOrAlias, text),

View file

@ -224,13 +224,17 @@ export class AuthService {
let removedTokens = 0;
for (const token of tokens) {
if (token.validUntil && token.validUntil.getTime() <= currentTime) {
this.logger.debug(`AuthToken '${token.keyId}' was removed`);
this.logger.debug(
`AuthToken '${token.keyId}' was removed`,
'removeInvalidTokens',
);
await this.authTokenRepository.remove(token);
removedTokens++;
}
}
this.logger.log(
`${removedTokens} invalid AuthTokens were purged from the DB.`,
'removeInvalidTokens',
);
}
}

View file

@ -144,7 +144,7 @@ export class NotesService {
noteIdOrAlias: string,
newPermissions: NotePermissionsUpdateDto,
): Note {
this.logger.warn('Using hardcoded data!');
this.logger.warn('Using hardcoded data!', 'updateNotePermissions');
return {
id: 'foobar-barfoo',
alias: null,