mirror of
https://github.com/darksaid98/new-phone-who-dis.git
synced 2026-12-04 14:38:45 +00:00
feat(server/debug): Added initial implementation of new Logger (#84)
- Logs out to a file w/ relevant meta data - Provides better readability for end user This should help provide better troubleshooting for both development and end users. This also fixes any previous catches that were attempting to print stack traces, causing the [object Object] message to appear. Co-authored-by: Christopher Gjelten <[email protected]>
This commit is contained in:
1 parent
a5491302b6
commit
211576e237
18 files changed
+363
-114
No files matched your search
@@ -1,7 +1,10 @@
|
||||
import events from '../utils/events';
|
||||
import { pool } from './db';
|
||||
import { useIdentifier, getSource } from './functions';
|
||||
import { useIdentifier } from './functions';
|
||||
import { Note, NoteId } from '../../phone/src/common/typings/notes';
|
||||
import { mainLogger } from './sv_logger';
|
||||
|
||||
const notesLogger = mainLogger.child({ module: 'notes' });
|
||||
|
||||
async function addNote(identifier: string, note: Note): Promise<any> {
|
||||
const query =
|
||||
@@ -29,27 +32,26 @@ async function updateNote(note: Note, identifier: string): Promise<any> {
|
||||
|
||||
onNet(events.NOTE_ADD_NOTE, async (note: Note) => {
|
||||
try {
|
||||
const pSource = (global as any).source
|
||||
const pSource = (global as any).source;
|
||||
const _identifier = await useIdentifier();
|
||||
await addNote(_identifier, note);
|
||||
emitNet(events.NOTE_SEND_NOTE_SUCCESS, pSource);
|
||||
emitNet(events.NOTE_ACTION_RESULT, pSource, { message: 'NOTES_ADD_SUCCESS', type: 'success' })
|
||||
|
||||
} catch (error) {
|
||||
const pSource = (global as any).source
|
||||
} catch (e) {
|
||||
const pSource = (global as any).source;
|
||||
notesLogger.error(`Failed to add note ${e.message}`);
|
||||
emitNet(events.NOTE_ACTION_RESULT, pSource, { message: 'NOTES_ADD_FAILED', type: 'error' })
|
||||
}
|
||||
});
|
||||
|
||||
onNet(events.NOTE_FETCH_ALL_NOTES, async () => {
|
||||
try {
|
||||
const pSource = (global as any).source
|
||||
const pSource = (global as any).source;
|
||||
const _identifier = await useIdentifier();
|
||||
const notes = await fetchAllNotes(_identifier);
|
||||
emitNet(events.NOTE_SEND_NOTE, pSource, notes);
|
||||
|
||||
} catch (error) {
|
||||
console.dir(error)
|
||||
} catch (e) {
|
||||
notesLogger.error(`Failed to fetch notes ${e.message}`);
|
||||
}
|
||||
});
|
||||
|
||||
@@ -60,9 +62,9 @@ onNet(events.NOTE_DELETE_NOTE, async (noteId: NoteId) => {
|
||||
await deleteNote(noteId.id, _identifier);
|
||||
|
||||
emitNet(events.NOTE_ACTION_RESULT, pSource, { message: 'NOTES_DELETE_SUCCESS', type: 'success' })
|
||||
|
||||
} catch (error) {
|
||||
} catch (e) {
|
||||
const pSource = (global as any).source;
|
||||
notesLogger.error(`Failed to delete note, ${e.message}`);
|
||||
emitNet(events.NOTE_ACTION_RESULT, pSource, { message: 'NOTES_DELETE_FAILED', type: 'error' })
|
||||
}
|
||||
});
|
||||
@@ -73,12 +75,12 @@ onNet(events.NOTE_UPDATE_NOTE, async (note: Note) => {
|
||||
const _identifier = await useIdentifier();
|
||||
await updateNote(note, _identifier);
|
||||
emitNet(events.NOTE_UPDATE_NOTE_SUCCESS, pSource);
|
||||
|
||||
emitNet(events.NOTE_ACTION_RESULT, pSource, { message: 'NOTES_UPDATE_SUCCESS', type: 'success' })
|
||||
|
||||
} catch (error) {
|
||||
} catch (e) {
|
||||
const pSource = (global as any).source;
|
||||
emitNet(events.NOTE_UPDATE_NOTE_FAILURE, pSource);
|
||||
notesLogger.error(`Failed to update note, ${e.message}`);
|
||||
emitNet(events.NOTE_ACTION_RESULT, pSource, { message: 'NOTES_UPDATE_FAILED', type: 'error' })
|
||||
}
|
||||
});
|
||||
|
||||
Reference in new issue
Block a user