Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 236
Expand file tree
/
Copy pathmain.py
More file actions
Latest commit
27 lines (22 loc) · 896 Bytes
/
Copy pathmain.py
File metadata and controls
27 lines (22 loc) · 896 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# usage: when generating the binding code, do cmake -DCCAPI_ENABLE_LOG_TRACE=ON ..., see https://github.com/crypto-chassis/ccapi#non-c
fromthreadingimportLock
importtime
fromccapiimportLogger, Session, Subscription
classMyLogger(Logger):
def__init__(self):
super().__init__()
self._lock=Lock()
deflogMessage(self, severity: str, threadId: str, timeISO: str, fileName: str, lineNumber: str, message: str) ->None:
self._lock.acquire()
print(f'{threadId}: [{timeISO}] {{{fileName}:{lineNumber}}} {severity}{" "*8}{message}')
self._lock.release()
myLogger=MyLogger()
Logger.logger=myLogger
if__name__=="__main__":
session=Session()
subscription=Subscription("coinbase", "BTC-USD", "MARKET_DEPTH")
session.subscribe(subscription)
time.sleep(10)
session.stop()
print("Bye")
Logger.logger=None