Add logging to test_server, fix it
This commit is contained in:
parent
14291ed863
commit
00fc46890e
@ -75,11 +75,11 @@ logger.setLevel(logging.DEBUG)
|
|||||||
logger.addHandler(ch)
|
logger.addHandler(ch)
|
||||||
|
|
||||||
server_pub_key = b64decode(config['public'][:-8])
|
server_pub_key = b64decode(config['public'][:-8])
|
||||||
# server_prv_key = b64decode(config['private'][:-8])
|
server_prv_key = b64decode(config['private'][:-8])
|
||||||
# sign = SigningKey(server_prv_key[:32])
|
sign = SigningKey(server_prv_key[:32])
|
||||||
|
|
||||||
loop = get_event_loop()
|
loop = get_event_loop()
|
||||||
packet_stream = PSClient('127.0.0.1', 8008, SigningKey.generate(), server_pub_key, loop=loop)
|
packet_stream = PSClient('127.0.0.1', 8008, sign, server_pub_key, loop=loop)
|
||||||
packet_stream.connect()
|
packet_stream.connect()
|
||||||
api.add_connection(packet_stream)
|
api.add_connection(packet_stream)
|
||||||
|
|
||||||
|
@ -1,8 +1,10 @@
|
|||||||
|
import logging
|
||||||
import os
|
import os
|
||||||
from asyncio import get_event_loop
|
from asyncio import get_event_loop, ensure_future
|
||||||
from base64 import b64decode
|
from base64 import b64decode
|
||||||
|
|
||||||
import yaml
|
import yaml
|
||||||
|
from colorlog import ColoredFormatter
|
||||||
from nacl.signing import SigningKey
|
from nacl.signing import SigningKey
|
||||||
|
|
||||||
from ssb.packet_stream import PSServer
|
from ssb.packet_stream import PSServer
|
||||||
@ -12,18 +14,25 @@ with open(os.path.expanduser('~/.ssb/secret')) as f:
|
|||||||
config = yaml.load(f)
|
config = yaml.load(f)
|
||||||
|
|
||||||
|
|
||||||
async def on_connect(server):
|
async def on_connect():
|
||||||
server.write('JSON', {
|
loop.create_task(ensure_future(packet_stream))
|
||||||
"name": ["createHistoryStream"],
|
|
||||||
"args": [{
|
# create console handler and set level to debug
|
||||||
"id": "@/Odg52x38pt7OivNnxK1Lm+H/+x6yV4DhMeXHBQRYc0=.ed25519",
|
ch = logging.StreamHandler()
|
||||||
"seq": 9,
|
ch.setLevel(logging.DEBUG)
|
||||||
"live": True,
|
|
||||||
"keys": False
|
# create formatter
|
||||||
}],
|
formatter = ColoredFormatter('%(log_color)s%(levelname)s%(reset)s:%(bold_white)s%(name)s%(reset)s - '
|
||||||
"type": "source"}, req=1)
|
'%(cyan)s%(message)s%(reset)s')
|
||||||
print(await server.read())
|
|
||||||
server.write('JSON', {})
|
# add formatter to ch
|
||||||
|
ch.setFormatter(formatter)
|
||||||
|
|
||||||
|
# add ch to logger
|
||||||
|
logger = logging.getLogger('packet_stream')
|
||||||
|
logger.setLevel(logging.DEBUG)
|
||||||
|
logger.addHandler(ch)
|
||||||
|
|
||||||
|
|
||||||
loop = get_event_loop()
|
loop = get_event_loop()
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user