forked from crypto-chassis/ccapi
- Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
Latest commit
21 lines (21 loc) · 756 Bytes
/
Copy pathmain.py
File metadata and controls
21 lines (21 loc) · 756 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
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