Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

order submit: don't spam log with standard messages #77

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

robertkowalski
Copy link
Contributor

@robertkowalski robertkowalski commented Apr 7, 2021

in case of errors like: "not enough exchange balance" we don't
need the full stack trace which bloats the log files

example:

bfx:hf:server:ws-server:api failed to submit order [bitfinex] Error: ERROR: Invalid order: maximum size for BTCUSD is 2000
    at WSv2._onWSNotification (/Users/robert/bitfinex/bfx-hf-ui/node_modules/bitfinex-api-node/lib/transports/ws2.js:672:41)
    at WSv2._handleAuthMessage (/Users/robert/bitfinex/bfx-hf-ui/node_modules/bitfinex-api-node/lib/transports/ws2.js:1150:14)
    at WSv2._handleChannelMessage (/Users/robert/bitfinex/bfx-hf-ui/node_modules/bitfinex-api-node/lib/transports/ws2.js:769:12)
    at WSv2._onWSMessage (/Users/robert/bitfinex/bfx-hf-ui/node_modules/bitfinex-api-node/lib/transports/ws2.js:729:12)
    at WebSocket.emit (events.js:314:20)
    at Receiver.receiverOnMessage (/Users/robert/bitfinex/bfx-hf-ui/node_modules/bitfinex-api-node/node_modules/ws/lib/websocket.js:825:20)
    at Receiver.emit (events.js:314:20)
    at Receiver.dataMessage (/Users/robert/bitfinex/bfx-hf-ui/node_modules/bitfinex-api-node/node_modules/ws/lib/receiver.js:437:14)
    at Receiver.getData (/Users/robert/bitfinex/bfx-hf-ui/node_modules/bitfinex-api-node/node_modules/ws/lib/receiver.js:367:17)
    at Receiver.startLoop (/Users/robert/bitfinex/bfx-hf-ui/node_modules/bitfinex-api-node/node_modules/ws/lib/receiver.js:143:22)
    at Receiver._write (/Users/robert/bitfinex/bfx-hf-ui/node_modules/bitfinex-api-node/node_modules/ws/lib/receiver.js:78:10)
    at doWrite (_stream_writable.js:403:12)
    at writeOrBuffer (_stream_writable.js:387:5)
    at Receiver.Writable.write (_stream_writable.js:318:11)
    at TLSSocket.socketOnData (/Users/robert/bitfinex/bfx-hf-ui/node_modules/bitfinex-api-node/node_modules/ws/lib/websocket.js:900:35)
    at TLSSocket.emit (events.js:314:20)
    at addChunk (_stream_readable.js:297:12)
    at readableAddChunk (_stream_readable.js:272:9)
    at TLSSocket.Readable.push (_stream_readable.js:213:10)
    at TLSWrap.onStreamRead (internal/stream_base_commons.js:188:23) +12s
  bfx:hf:server:ws-server:api failed to submit order [bitfinex] Error: ERROR: Invalid order: not enough exchange balance for 30 BTCUSD at 50000
    at WSv2._onWSNotification (/Users/robert/bitfinex/bfx-hf-ui/node_modules/bitfinex-api-node/lib/transports/ws2.js:672:41)
    at WSv2._handleAuthMessage (/Users/robert/bitfinex/bfx-hf-ui/node_modules/bitfinex-api-node/lib/transports/ws2.js:1150:14)
    at WSv2._handleChannelMessage (/Users/robert/bitfinex/bfx-hf-ui/node_modules/bitfinex-api-node/lib/transports/ws2.js:769:12)
    at WSv2._onWSMessage (/Users/robert/bitfinex/bfx-hf-ui/node_modules/bitfinex-api-node/lib/transports/ws2.js:729:12)
    at WebSocket.emit (events.js:314:20)
    at Receiver.receiverOnMessage (/Users/robert/bitfinex/bfx-hf-ui/node_modules/bitfinex-api-node/node_modules/ws/lib/websocket.js:825:20)
    at Receiver.emit (events.js:314:20)
    at Receiver.dataMessage (/Users/robert/bitfinex/bfx-hf-ui/node_modules/bitfinex-api-node/node_modules/ws/lib/receiver.js:437:14)
    at Receiver.getData (/Users/robert/bitfinex/bfx-hf-ui/node_modules/bitfinex-api-node/node_modules/ws/lib/receiver.js:367:17)
    at Receiver.startLoop (/Users/robert/bitfinex/bfx-hf-ui/node_modules/bitfinex-api-node/node_modules/ws/lib/receiver.js:143:22)
    at Receiver._write (/Users/robert/bitfinex/bfx-hf-ui/node_modules/bitfinex-api-node/node_modules/ws/lib/receiver.js:78:10)
    at doWrite (_stream_writable.js:403:12)
    at writeOrBuffer (_stream_writable.js:387:5)
    at Receiver.Writable.write (_stream_writable.js:318:11)
    at TLSSocket.socketOnData (/Users/robert/bitfinex/bfx-hf-ui/node_modules/bitfinex-api-node/node_modules/ws/lib/websocket.js:900:35)
    at TLSSocket.emit (events.js:314:20)
    at addChunk (_stream_readable.js:297:12)
    at readableAddChunk (_stream_readable.js:272:9)
    at TLSSocket.Readable.push (_stream_readable.js:213:10)
    at TLSWrap.onStreamRead (internal/stream_base_commons.js:188:23) +24s

in case of errors like: "not enough exchange balance" we don't
need the full stack trace which bloats the log files
Copy link

@ghost ghost left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perhaps extracting the 'message' property from an Error instance can be implemented in the 'd' function as a wrapper over Debug?

this.d = Debug(`bfx:hf:server:ws-server:${debugName}`)

this.d = Debug(`bfx:hf:server:ws-client:${debugName}`)

Then the logs will contain the 'message' property from an Error instance, for example:

d('failed to submit order', error) // will print error.message if error is isntance of Error or it is an object and contains 'message' property 

Another module I found, is ./lib/capture.js
It seems that it is intended to log the stack trace if necessary, otherwise we can pass an Error instance into 'd'.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant