metaapi / metaapi-javascript-sdk

Browser and node.js javascript SDK for MetaApi, a professional cloud forex trading API for MetaTrader platform which supports both MetaTrader MetaTrader 5 and MetaTrader 4. Free usage tier available.
https://metaapi.cloud
Other
30 stars 3 forks source link

Disable logs or adjust log level #9

Closed banjo closed 2 months ago

banjo commented 2 months ago

I'm using the SDK in production but currently its logs are taking over for me. I constantly get this error message, several times per day. Even though everything seem to work.

2024-08-06T08:17:43.874376371Z app[web.1]: [2024-08-06T08:17:43.873Z] f2017ca8-f2fb-4411-8e0a-1845bdb51c20:1: Failed to subscribe TimeoutError: It seems like the account f2017ca8-f2fb-4411-8e0a-1845bdb51c20 is not connected to broker yet or SDK settings you use does not match the account region. Please make sure account is connected to broker before retrying the request. Please make sure you pass a region option to MetaApi constructor for Java SDK. Please make sure you do not pass region option to MetaApi constructor for javascript and python SDKs.
2024-08-06T08:17:43.874414612Z app[web.1]:     at MetaApiWebsocketClient._convertError (/usr/src/app/node_modules/.pnpm/metaapi.cloud-sdk@27.1.1/node_modules/metaapi.cloud-sdk/dist/clients/metaApi/metaApiWebsocket.client.js:1440:20)
2024-08-06T08:17:43.874419572Z app[web.1]:     at Socket.<anonymous> (/usr/src/app/node_modules/.pnpm/metaapi.cloud-sdk@27.1.1/node_modules/metaapi.cloud-sdk/dist/clients/metaApi/metaApiWebsocket.client.js:365:40)
2024-08-06T08:17:43.874423852Z app[web.1]:     at Emitter.emit (/usr/src/app/node_modules/.pnpm/component-emitter@1.3.1/node_modules/component-emitter/index.js:145:20)
2024-08-06T08:17:43.874427252Z app[web.1]:     at Socket.onevent (/usr/src/app/node_modules/.pnpm/socket.io-client@2.4.0_bufferutil@4.0.8_utf-8-validate@5.0.10/node_modules/socket.io-client/lib/socket.js:278:10)
2024-08-06T08:17:43.874430812Z app[web.1]:     at Socket.onpacket (/usr/src/app/node_modules/.pnpm/socket.io-client@2.4.0_bufferutil@4.0.8_utf-8-validate@5.0.10/node_modules/socket.io-client/lib/socket.js:236:12)
2024-08-06T08:17:43.874434652Z app[web.1]:     at Manager.<anonymous> (/usr/src/app/node_modules/.pnpm/component-bind@1.0.0/node_modules/component-bind/index.js:21:15)
2024-08-06T08:17:43.874438292Z app[web.1]:     at Emitter.emit (/usr/src/app/node_modules/.pnpm/component-emitter@1.3.1/node_modules/component-emitter/index.js:145:20)
2024-08-06T08:17:43.874442132Z app[web.1]:     at Manager.ondecoded (/usr/src/app/node_modules/.pnpm/socket.io-client@2.4.0_bufferutil@4.0.8_utf-8-validate@5.0.10/node_modules/socket.io-client/lib/manager.js:349:8)
2024-08-06T08:17:43.874446052Z app[web.1]:     at Decoder.<anonymous> (/usr/src/app/node_modules/.pnpm/component-bind@1.0.0/node_modules/component-bind/index.js:21:15)
2024-08-06T08:17:43.874449572Z app[web.1]:     at Emitter.emit (/usr/src/app/node_modules/.pnpm/component-emitter@1.3.1/node_modules/component-emitter/index.js:145:20)

You can see an example below.

CleanShot 2024-08-06 at 10 50 52@2x

I'm not sure why it is showing up, or what I can do about it but I would love to either fix it, or at least be able to manage the log level myself if that is possible.

metaapi commented 2 months ago

Hello, you can use log4js to solve this as per https://github.com/metaapi/metaapi-javascript-sdk/blob/main/docs/logging.md

metaapi commented 2 months ago

Please also make sure to use the latest SDK version (27.2.0 at the time of writing this message), as we've recently improved the logging in SDK to move excessive logs to debug level.