Mercurial > libervia-web
diff libervia_server/__init__.py @ 438:582c435dab6b
server side: new log system is used
author | Goffi <goffi@goffi.org> |
---|---|
date | Thu, 08 May 2014 17:21:30 +0200 |
parents | e63fc04efef7 |
children | b64e528fb524 |
line wrap: on
line diff
--- a/libervia_server/__init__.py Tue May 06 23:08:08 2014 +0200 +++ b/libervia_server/__init__.py Thu May 08 17:21:30 2014 +0200 @@ -22,7 +22,6 @@ glib2reactor.install() from twisted.internet import reactor, defer from twisted.web import server -from twisted.web import error as weberror from twisted.web.static import File from twisted.web.resource import Resource, NoResource from twisted.web.util import Redirect, redirectTo @@ -32,7 +31,8 @@ from txjsonrpc.web import jsonrpc from txjsonrpc import jsonrpclib -from logging import debug, info, warning, error +from sat.core.log import getLogger +log = getLogger(__name__) import re import glob import os.path @@ -115,7 +115,7 @@ def purgeID(self, action_tuple): """Called when an action_id has not be handled in time""" if action_tuple in self.waiting_ids: - warning ("action of action_id %s [%s] has not been managed, action_id is now ignored" % action_tuple) + log.warning ("action of action_id %s [%s] has not been managed, action_id is now ignored" % action_tuple) del self.waiting_ids[action_tuple] def actionResultCb(self, answer_type, action_id, data, profile): @@ -350,10 +350,10 @@ profile = sat_session.profile sat_jid = sat_session.jid if not sat_jid: - error("No jid saved for this profile") + log.error("No jid saved for this profile") return {} if JID(from_jid).userhost() != sat_jid.userhost() and JID(to_jid).userhost() != sat_jid.userhost(): - error("Trying to get history from a different jid, maybe a hack attempt ?") + log.error("Trying to get history from a different jid, maybe a hack attempt ?") return {} d = self.asyncBridgeCall("getHistory", from_jid, to_jid, size, between, profile) def show(result_dbus): @@ -376,7 +376,7 @@ if room_jid != "": room_jid = JID(room_jid).userhost() except: - warning('Invalid room jid') + log.warning('Invalid room jid') return d = self.asyncBridgeCall("joinMUC", room_jid, nick, {}, profile) return d @@ -387,7 +387,7 @@ try: room_jid = JID(room_jid).userhost() except: - warning('Invalid room jid') + log.warning('Invalid room jid') return room_id = room_jid.split("@")[0] service = room_jid.split("@")[1] @@ -399,7 +399,7 @@ try: room_jid = JID(room_jid) except: - warning('Invalid room jid') + log.warning('Invalid room jid') return self.sat_host.bridge.mucLeave(room_jid.userhost(), profile) @@ -417,7 +417,7 @@ if room_jid != "": room_jid = JID(room_jid).userhost() except: - warning('Invalid room jid') + log.warning('Invalid room jid') return self.sat_host.bridge.tarotGameLaunch(other_players, room_jid, profile) @@ -446,7 +446,7 @@ if room_jid != "": room_jid = JID(room_jid).userhost() except: - warning('Invalid room jid') + log.warning('Invalid room jid') return self.sat_host.bridge.radiocolLaunch(invited, room_jid, profile) @@ -505,7 +505,7 @@ if category in self.authorized_params and name in self.authorized_params[category]: return self.sat_host.bridge.setParam(name, value, category, C.SECURITY_LIMIT, profile) else: - warning("Trying to set parameter '%s' in category '%s' without authorization!!!" + log.warning("Trying to set parameter '%s' in category '%s' without authorization!!!" % (name, category)) def jsonrpc_launchAction(self, callback_id, data): @@ -632,7 +632,7 @@ return d def profile_pass_errback(ignore): - error("INTERNAL ERROR: can't check profile password") + log.error("INTERNAL ERROR: can't check profile password") request.write("AUTH ERROR") request.finish() @@ -668,7 +668,7 @@ elif reason == "InternalError": request.write('INTERNAL') else: - error('Unknown registering error: %s' % (reason,)) + log.error('Unknown registering error: %s' % (reason,)) request.write('Unknown error (%s)' % reason) request.finish() @@ -698,13 +698,13 @@ _session = request.getSession() sat_session = ISATSession(_session) if sat_session.profile: - error (('/!\\ Session has already a profile, this should NEVER happen !')) + log.error (('/!\\ Session has already a profile, this should NEVER happen !')) return result('SESSION_ACTIVE') sat_session.profile = profile self.sat_host.prof_connected.add(profile) def onExpire(): - info ("Session expired (profile=%s)" % (profile,)) + log.info ("Session expired (profile=%s)" % (profile,)) try: #We purge the queue del self.sat_host.signal_handler.queue[profile] @@ -814,10 +814,10 @@ try: source_defer = self.signalDeferred[profile] if source_defer.called and source_defer.result[0] == "disconnected": - info(u"[%s] disconnected" % (profile,)) + log.info(u"[%s] disconnected" % (profile,)) _session.expire() except IndexError: - error("Deferred result should be a tuple with fonction name first") + log.error("Deferred result should be a tuple with fonction name first") self.signalDeferred[profile] = defer.Deferred() self.request.notifyFinish().addBoth(unlock, profile) @@ -847,7 +847,7 @@ def disconnected(self, profile): if not profile in self.sat_host.prof_connected: - error("'disconnected' signal received for a not connected profile") + log.error("'disconnected' signal received for a not connected profile") return self.sat_host.prof_connected.remove(profile) if profile in self.signalDeferred: @@ -1071,10 +1071,10 @@ try: cert = ssl.PrivateCertificate.loadPEM(keyAndCert.read()) except OpenSSL.crypto.Error as e: - error(_("The file '%s' must contain both private and public parts of the certificate") % self.ssl_certificate) + log.error(_("The file '%s' must contain both private and public parts of the certificate") % self.ssl_certificate) raise e except IOError as e: - error(_("The file '%s' doesn't exist") % self.ssl_certificate) + log.error(_("The file '%s' doesn't exist") % self.ssl_certificate) raise e reactor.listenSSL(self.port_https, self.site, cert.options()) if self.connection_type in ('http', 'both'):