use python logging
This commit is contained in:
parent
d9346e8328
commit
6a8a7b956d
27 changed files with 174 additions and 141 deletions
|
|
@ -9,6 +9,9 @@ from user.models import User
|
|||
import state
|
||||
from websocket import trigger_event
|
||||
|
||||
import logging
|
||||
logger = logging.getLogger('oml.node.api')
|
||||
|
||||
def api_pullChanges(app, remote_id, user_id=None, from_=None, to=None):
|
||||
if user_id and not from_ and not to:
|
||||
from_ = user_id
|
||||
|
|
@ -34,7 +37,7 @@ def api_pullChanges(app, remote_id, user_id=None, from_=None, to=None):
|
|||
def api_pushChanges(app, user_id, changes):
|
||||
user = User.get(user_id)
|
||||
if not Changelog.apply_changes(user, changes):
|
||||
print 'FAILED TO APPLY CHANGE'
|
||||
logger.debug('FAILED TO APPLY CHANGE')
|
||||
state.nodes.queue(user_id, 'pullChanges')
|
||||
return False
|
||||
return True
|
||||
|
|
@ -58,7 +61,7 @@ def api_requestPeering(app, user_id, username, message):
|
|||
|
||||
def api_acceptPeering(app, user_id, username, message):
|
||||
user = User.get(user_id)
|
||||
print 'incoming acceptPeering event: pending:', user.pending
|
||||
logger.debug('incoming acceptPeering event: pending: %s', user.pending)
|
||||
if user and user.pending == 'sent':
|
||||
if not user.info:
|
||||
user.info = {}
|
||||
|
|
|
|||
|
|
@ -18,6 +18,9 @@ from ed25519_utils import valid
|
|||
import api
|
||||
import cert
|
||||
|
||||
import logging
|
||||
logger = logging.getLogger('oml.node.server')
|
||||
|
||||
class NodeHandler(tornado.web.RequestHandler):
|
||||
|
||||
def initialize(self, app):
|
||||
|
|
@ -44,7 +47,7 @@ class NodeHandler(tornado.web.RequestHandler):
|
|||
content = {}
|
||||
if valid(key, data, sig):
|
||||
action, args = json.loads(data)
|
||||
print key, 'action', action, args
|
||||
logger.debug('%s action %s %s', key, action, args)
|
||||
if action == 'ping':
|
||||
content = {
|
||||
'ip': request.remote_addr
|
||||
|
|
@ -57,7 +60,7 @@ class NodeHandler(tornado.web.RequestHandler):
|
|||
) or (u and u.peered):
|
||||
content = getattr(api, 'api_' + action)(self.app, key, *args)
|
||||
else:
|
||||
print 'PEER', key, 'IS UNKNOWN SEND 403'
|
||||
logger.debug('PEER %s IS UNKNOWN SEND 403', key)
|
||||
self.set_status(403)
|
||||
content = {
|
||||
'status': 'not peered'
|
||||
|
|
@ -91,7 +94,7 @@ class ShareHandler(tornado.web.RequestHandler):
|
|||
'txt': 'text/plain',
|
||||
}.get(path.split('.')[-1], None)
|
||||
self.set_header('Content-Type', mimetype)
|
||||
print 'GET file', id
|
||||
logger.debug('GET file %s', id)
|
||||
with open(path, 'rb') as f:
|
||||
while 1:
|
||||
data = f.read(16384)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue