# HG changeset patch # User Goffi # Date 1399562490 -7200 # Node ID 582c435dab6b294e5632b82fa04e1efaf0ec6f86 # Parent fa3b65b689715ba8456c611fd1b99f717fee4315 server side: new log system is used diff -r fa3b65b68971 -r 582c435dab6b constants.py --- a/constants.py Tue May 06 23:08:08 2014 +0200 +++ b/constants.py Thu May 08 17:21:30 2014 +0200 @@ -17,7 +17,7 @@ # You should have received a copy of the GNU Affero General Public License # along with this program. If not, see . -from sat.core.i18n import _, D_ +from sat.core.i18n import D_ from sat_frontends import constants @@ -44,3 +44,4 @@ # Frontend parameters ENABLE_UNIBOX_KEY = D_("Composition") ENABLE_UNIBOX_PARAM = D_("Enable unibox") + LOG_OPT_SECTION = APP_NAME.lower() diff -r fa3b65b68971 -r 582c435dab6b libervia_server/__init__.py --- 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'): diff -r fa3b65b68971 -r 582c435dab6b twisted/plugins/libervia.py --- a/twisted/plugins/libervia.py Tue May 06 23:08:08 2014 +0200 +++ b/twisted/plugins/libervia.py Thu May 08 17:21:30 2014 +0200 @@ -28,13 +28,17 @@ except ImportError: pass +# XXX: We need to configure logs before any log method is used, so here is the best place. +from constants import Const as C +from sat.core import log +log.satConfigure(C.LOG_BACKEND_TWISTED, C) + from zope.interface import implements from twisted.python import usage from twisted.plugin import IPlugin from twisted.application.service import IServiceMaker -from xdg.BaseDirectory import save_config_path from ConfigParser import SafeConfigParser, NoSectionError, NoOptionError from sat.core.constants import Const as C try: