Skip to content
This repository has been archived by the owner on Aug 27, 2024. It is now read-only.

Commit

Permalink
logging updates
Browse files Browse the repository at this point in the history
  • Loading branch information
CelestialCrafter committed Dec 13, 2023
1 parent 9f03dbd commit 0a5cc1e
Show file tree
Hide file tree
Showing 4 changed files with 62 additions and 13 deletions.
7 changes: 4 additions & 3 deletions src/blockchain/approval.js
Original file line number Diff line number Diff line change
Expand Up @@ -96,9 +96,10 @@ const executeApproval = async (privateKey, { id, strengthToUSD, baseToken = defa

export default async tradeData => {
const promises = await Promise.allSettled(
tradeData.map(({ id, strengthToUSD, privateKey }) =>
executeApproval(privateKey, { strengthToUSD, id })
)
tradeData.map(({ id, strengthToUSD, privateKey }) => ({
approvals: executeApproval(privateKey, { strengthToUSD, id }),
id
}))
);

return promises.filter(p => !(p.status === 'fulfilled' && p.value.length < 1));
Expand Down
51 changes: 48 additions & 3 deletions src/blockchain/check.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,9 +69,54 @@ export default async redis => {
);
const worthsResults = await addWorths(tradeData);

log.info(transactionResults, 'transactions');
log.info(worthsResults, 'worths');
log.info(approvalResults, 'approvals');
transactionResults.forEach(result =>
result.status === 'fulfilled'
? log.debug(
{
transaction: result.value.transaction,
id: result.value.id
},
'transaction'
)
: log.warn(
{
error: result.reason
},
'transaction error'
)
);

worthsResults.forEach(result =>
result.status === 'fulfilled'
? log.debug(
{
...result.value
},
'worth'
)
: log.warn(
{
error: result.reason
},
'worth error'
)
);

approvalResults.forEach(result =>
result.status === 'fulfilled'
? log.debug(
{
...result.value
},
'approval'
)
: log.warn(
{
error: result.reason
},
'approval error'
)
);

// Update worths
Bot.bulkWrite(
Expand Down
9 changes: 5 additions & 4 deletions src/blockchain/trading.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,11 +58,12 @@ const executeTransaction = async (

export default tradeData =>
Promise.allSettled(
tradeData.map(({ signal: action, amount: baseAmount, privateKey }) =>
executeTransaction(privateKey, {
tradeData.map(({ id, signal: action, amount: baseAmount, privateKey }) => ({
transaction: executeTransaction(privateKey, {
modToken: tokens.wrapped,
baseAmount,
action
})
)
}),
id
}))
);
8 changes: 5 additions & 3 deletions src/lib/logging.server.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import bunyan from 'bunyan';
import bunyan, { TRACE } from 'bunyan';
const { WARN, createLogger, stdSerializers } = bunyan;

const transactionSerializer = transaction => {
Expand Down Expand Up @@ -39,10 +39,12 @@ export const log = createLogger({
name: 'main-server',
streams: [
{
path: 'server.log'
path: 'server.log',
level: TRACE
},
{
stream: process.stdout
stream: process.stdout,
level: TRACE
},
{
stream: process.stderr,
Expand Down

0 comments on commit 0a5cc1e

Please sign in to comment.