LUCIT-Systems-and-Development / unicorn-binance-websocket-api

A Python SDK by LUCIT to use the Binance Websocket API`s (com+testnet, com-margin+testnet, com-isolated_margin+testnet, com-futures+testnet, com-coin_futures, us, tr, dex/chain+testnet) in a simple, fast, flexible, robust and fully-featured way.
https://unicorn-binance-websocket-api.docs.lucit.tech/
Other
678 stars 166 forks source link

Screen output while the stream is active #185

Closed aleangelin88 closed 2 years ago

aleangelin88 commented 2 years ago

Is it possible to re-direct the messages like the one shown below to a file or to a normal logging stream? Thank you

INFO:root:BinanceWebSocketApiSocket.start_socket(9e050e79-3d4b-452e-8e2d-31fd5826b736) - Received result message: {"result":null,"id":1} INFO:root:BinanceWebSocketApiManager._frequent_checks() - reached new highest_receiving_speed 8.66 kB/s at 2021-07-23, 12:36:02 UTC INFO:root:BinanceWebSocketApiManager._frequent_checks() - reached new highest_receiving_speed 11.21 kB/s at 2021-07-23, 12:36:03 UTC INFO:root:BinanceWebSocketApiManager._frequent_checks() - reached new highest_receiving_speed 14.41 kB/s at 2021-07-23, 12:36:04 UTC INFO:root:BinanceWebSocketApiManager._frequent_checks() - reached new highest_receiving_speed 16.06 kB/s at 2021-07-23, 12:36:05 UTC

oliver-zehentleitner commented 2 years ago

Sure! Just add this to the top of your file:

import logging

logging.basicConfig(level=logging.DEBUG,
                    filename=os.path.basename(__file__) + '.log',
                    format="{asctime} [{levelname:8}] {process} {thread} {module}: {message}",
                    style="{")
oliver-zehentleitner commented 2 years ago

Feel free to reopen if needed....