mirror of
https://github.com/darksaid98/new-phone-who-dis.git
synced 2026-12-04 22:16:40 +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
@@ -7,7 +7,9 @@ import {
|
||||
IBankCredentials,
|
||||
} from '../../phone/src/common/typings/bank';
|
||||
import { useIdentifier } from './functions';
|
||||
import { type } from 'os';
|
||||
import { mainLogger } from './sv_logger';
|
||||
|
||||
const bankLogger = mainLogger.child({ module: 'bank' });
|
||||
|
||||
async function fetchAllTransactions(identifier: string): Promise<Transfer[]> {
|
||||
const query =
|
||||
@@ -15,6 +17,10 @@ async function fetchAllTransactions(identifier: string): Promise<Transfer[]> {
|
||||
const [results] = await pool.query(query, [identifier]);
|
||||
const transactions = <Transfer[]>results;
|
||||
|
||||
bankLogger.verbose(
|
||||
`Fetched all transactions (${identifier}) - ${JSON.stringify(transactions)}`
|
||||
);
|
||||
|
||||
return transactions;
|
||||
}
|
||||
|
||||
@@ -27,6 +33,8 @@ function fetchCredentials(): IBankCredentials {
|
||||
balance,
|
||||
};
|
||||
|
||||
bankLogger.verbose(`Fetching banking credentials - ${name} - ${balance}`);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -83,8 +91,8 @@ onNet(events.BANK_FETCH_TRANSACTIONS, async () => {
|
||||
const transfer = await fetchAllTransactions(_identifier);
|
||||
|
||||
emitNet(events.BANK_SEND_TRANSFERS, _source, transfer);
|
||||
} catch (error) {
|
||||
console.log('Failed to fetch transactions');
|
||||
} catch (e) {
|
||||
bankLogger.error(`Failed to fetch transactions, ${e.message}`);
|
||||
}
|
||||
});
|
||||
|
||||
@@ -95,7 +103,8 @@ onNet(events.BANK_ADD_TRANSFER, async (transfer: Transfer) => {
|
||||
const transferNotify = await addTransfer(_identifier, transfer);
|
||||
emitNet(events.BANK_TRANSACTION_NOTIFICATION, xTarget, transferNotify);
|
||||
emitNet(events.BANK_ADD_TRANSFER_SUCCESS, getSource());
|
||||
} catch (error) {
|
||||
} catch (e) {
|
||||
bankLogger.error(`Failed to add transaction, ${e.message}`);
|
||||
emitNet(events.BANK_TRANSACTION_ALERT, getSource(), false);
|
||||
}
|
||||
});
|
||||
@@ -104,7 +113,7 @@ onNet(events.BANK_GET_CREDENTIALS, () => {
|
||||
try {
|
||||
const credentials = fetchCredentials();
|
||||
emitNet(events.BANK_SEND_CREDENTIALS, getSource(), credentials);
|
||||
} catch (error) {
|
||||
console.log('Failed to fetch credentials');
|
||||
} catch (e) {
|
||||
bankLogger.error(`Failed to fetch credentials, ${e.message}`);
|
||||
}
|
||||
});
|
||||
Reference in new issue
Block a user