Fix some logging calls
- Add logging domain to some modules - Log to module domain instead of generic 'gajim'
This commit is contained in:
		
							parent
							
								
									f8f84338b2
								
							
						
					
					
						commit
						3e764c3d35
					
				
					 7 changed files with 29 additions and 18 deletions
				
			
		| 
						 | 
				
			
			@ -1473,7 +1473,7 @@ class Connection(CommonConnection, ConnectionHandlers):
 | 
			
		|||
            if not app.config.get_per('accounts', self.name, 'savepass'):
 | 
			
		||||
                # Forget password, it's wrong
 | 
			
		||||
                self.password = None
 | 
			
		||||
            app.log.debug("Couldn't authenticate to %s" % self._hostname)
 | 
			
		||||
            log.debug("Couldn't authenticate to %s" % self._hostname)
 | 
			
		||||
            self.disconnect(on_purpose = True)
 | 
			
		||||
            app.nec.push_incoming_event(OurShowEvent(None, conn=self,
 | 
			
		||||
                show='offline'))
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -25,12 +25,15 @@
 | 
			
		|||
##
 | 
			
		||||
 | 
			
		||||
import os
 | 
			
		||||
import logging
 | 
			
		||||
 | 
			
		||||
from gajim.common import app
 | 
			
		||||
from gajim.common import exceptions
 | 
			
		||||
 | 
			
		||||
_GAJIM_ERROR_IFACE = 'org.gajim.dbus.Error'
 | 
			
		||||
 | 
			
		||||
log = logging.getLogger('gajim.c.dbus')
 | 
			
		||||
 | 
			
		||||
try:
 | 
			
		||||
    import dbus
 | 
			
		||||
    from dbus.mainloop.glib import DBusGMainLoop
 | 
			
		||||
| 
						 | 
				
			
			@ -155,7 +158,7 @@ def get_interface(interface, path, start_service=True):
 | 
			
		|||
        obj = bus.get_object(interface, path)
 | 
			
		||||
        return dbus.Interface(obj, interface)
 | 
			
		||||
    except Exception as e:
 | 
			
		||||
        app.log.debug(str(e))
 | 
			
		||||
        log.debug(str(e))
 | 
			
		||||
        return None
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -23,6 +23,9 @@
 | 
			
		|||
 | 
			
		||||
from gajim.common import app
 | 
			
		||||
import os
 | 
			
		||||
import logging
 | 
			
		||||
 | 
			
		||||
log = logging.getLogger('gajim.c.sleepy')
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
STATE_UNKNOWN  = 'OS probably not supported'
 | 
			
		||||
| 
						 | 
				
			
			@ -52,7 +55,7 @@ try:
 | 
			
		|||
        from gajim.common import idle
 | 
			
		||||
        idle.xss_available
 | 
			
		||||
except Exception:
 | 
			
		||||
    app.log.debug('Unable to load idle module')
 | 
			
		||||
    log.debug('Unable to load idle module')
 | 
			
		||||
    SUPPORTED = False
 | 
			
		||||
 | 
			
		||||
class SleepyWindows:
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -20,8 +20,11 @@
 | 
			
		|||
from gajim.common import app
 | 
			
		||||
import select
 | 
			
		||||
import re
 | 
			
		||||
import logging
 | 
			
		||||
from gajim.common.zeroconf.zeroconf import Constant
 | 
			
		||||
 | 
			
		||||
log = logging.getLogger('gajim.c.z.zeroconf_bonjour')
 | 
			
		||||
 | 
			
		||||
try:
 | 
			
		||||
    import pybonjour
 | 
			
		||||
except ImportError:
 | 
			
		||||
| 
						 | 
				
			
			@ -56,7 +59,7 @@ class Zeroconf:
 | 
			
		|||
 | 
			
		||||
 | 
			
		||||
    def browse_callback(self, sdRef, flags, interfaceIndex, errorCode, serviceName, regtype, replyDomain):
 | 
			
		||||
        app.log.debug('Found service %s in domain %s on %i(type: %s).' % (serviceName, replyDomain, interfaceIndex, regtype))
 | 
			
		||||
        log.debug('Found service %s in domain %s on %i(type: %s).' % (serviceName, replyDomain, interfaceIndex, regtype))
 | 
			
		||||
        if not self.connected:
 | 
			
		||||
            return
 | 
			
		||||
        if errorCode != pybonjour.kDNSServiceErr_NoError:
 | 
			
		||||
| 
						 | 
				
			
			@ -72,7 +75,7 @@ class Zeroconf:
 | 
			
		|||
            while not self.resolved:
 | 
			
		||||
                ready = select.select([resolve_sdRef], [], [], resolve_timeout)
 | 
			
		||||
                if resolve_sdRef not in ready[0]:
 | 
			
		||||
                    app.log.debug('Resolve timed out')
 | 
			
		||||
                    log.debug('Resolve timed out')
 | 
			
		||||
                    break
 | 
			
		||||
                pybonjour.DNSServiceProcessResult(resolve_sdRef)
 | 
			
		||||
            else:
 | 
			
		||||
| 
						 | 
				
			
			@ -81,7 +84,7 @@ class Zeroconf:
 | 
			
		|||
            resolve_sdRef.close()
 | 
			
		||||
 | 
			
		||||
    def remove_service_callback(self, name):
 | 
			
		||||
        app.log.debug('Service %s disappeared.' % name)
 | 
			
		||||
        log.debug('Service %s disappeared.' % name)
 | 
			
		||||
        if not self.connected:
 | 
			
		||||
            return
 | 
			
		||||
        if name != self.name:
 | 
			
		||||
| 
						 | 
				
			
			@ -121,8 +124,8 @@ class Zeroconf:
 | 
			
		|||
 | 
			
		||||
        txt = pybonjour.TXTRecord.parse(txtRecord)
 | 
			
		||||
 | 
			
		||||
        app.log.debug('Service data for service %s on %i:' % (fullname, interfaceIndex))
 | 
			
		||||
        app.log.debug('Host %s, port %i, TXT data: %s' % (hosttarget, port, txt._items))
 | 
			
		||||
        log.debug('Service data for service %s on %i:' % (fullname, interfaceIndex))
 | 
			
		||||
        log.debug('Host %s, port %i, TXT data: %s' % (hosttarget, port, txt._items))
 | 
			
		||||
 | 
			
		||||
        if not self.connected:
 | 
			
		||||
            return
 | 
			
		||||
| 
						 | 
				
			
			@ -176,11 +179,11 @@ class Zeroconf:
 | 
			
		|||
 | 
			
		||||
    def service_added_callback(self, sdRef, flags, errorCode, name, regtype, domain):
 | 
			
		||||
        if errorCode == pybonjour.kDNSServiceErr_NoError:
 | 
			
		||||
            app.log.debug('Service successfully added')
 | 
			
		||||
            log.debug('Service successfully added')
 | 
			
		||||
 | 
			
		||||
    def service_add_fail_callback(self, err):
 | 
			
		||||
        if err[0][0] == pybonjour.kDNSServiceErr_NameConflict:
 | 
			
		||||
            app.log.debug('Error while adding service. %s' % str(err))
 | 
			
		||||
            log.debug('Error while adding service. %s' % str(err))
 | 
			
		||||
            parts = self.username.split(' ')
 | 
			
		||||
 | 
			
		||||
            #check if last part is a number and if, increment it
 | 
			
		||||
| 
						 | 
				
			
			@ -230,7 +233,7 @@ class Zeroconf:
 | 
			
		|||
        except pybonjour.BonjourError as e:
 | 
			
		||||
            self.service_add_fail_callback(e)
 | 
			
		||||
        else:
 | 
			
		||||
            app.log.debug('Publishing service %s of type %s' % (self.name, self.stype))
 | 
			
		||||
            log.debug('Publishing service %s of type %s' % (self.name, self.stype))
 | 
			
		||||
 | 
			
		||||
            ready = select.select([sdRef], [], [], resolve_timeout)
 | 
			
		||||
            if sdRef in ready[0]:
 | 
			
		||||
| 
						 | 
				
			
			@ -252,7 +255,7 @@ class Zeroconf:
 | 
			
		|||
            self.announced = False
 | 
			
		||||
            return True
 | 
			
		||||
        except pybonjour.BonjourError as e:
 | 
			
		||||
            app.log.debug(e)
 | 
			
		||||
            log.debug(e)
 | 
			
		||||
            return False
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -282,7 +285,7 @@ class Zeroconf:
 | 
			
		|||
                self.remove_announce()
 | 
			
		||||
 | 
			
		||||
    def browse_domain(self, domain=None):
 | 
			
		||||
        app.log.debug('starting to browse')
 | 
			
		||||
        log.debug('starting to browse')
 | 
			
		||||
        try:
 | 
			
		||||
            self.browse_sdRef = pybonjour.DNSServiceBrowse(regtype=self.stype, domain=domain, callBack=self.browse_callback)
 | 
			
		||||
        except pybonjour.BonjourError as e:
 | 
			
		||||
| 
						 | 
				
			
			@ -310,7 +313,7 @@ class Zeroconf:
 | 
			
		|||
            try:
 | 
			
		||||
                ready = select.select([resolve_sdRef], [], [], resolve_timeout)
 | 
			
		||||
                if resolve_sdRef not in ready[0]:
 | 
			
		||||
                    app.log.debug('Resolve timed out (in resolve_all)')
 | 
			
		||||
                    log.debug('Resolve timed out (in resolve_all)')
 | 
			
		||||
                    break
 | 
			
		||||
                pybonjour.DNSServiceProcessResult(resolve_sdRef)
 | 
			
		||||
            finally:
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1358,8 +1358,8 @@ class ConversationTextview(GObject.GObject):
 | 
			
		|||
                self.tv.display_html(xhtml, self.tv, self, iter_=iter_)
 | 
			
		||||
                return
 | 
			
		||||
            except Exception as e:
 | 
			
		||||
                app.log.debug('Error processing xhtml: ' + str(e))
 | 
			
		||||
                app.log.debug('with |' + xhtml + '|')
 | 
			
		||||
                log.debug('Error processing xhtml: ' + str(e))
 | 
			
		||||
                log.debug('with |' + xhtml + '|')
 | 
			
		||||
 | 
			
		||||
        # /me is replaced by name if name is given
 | 
			
		||||
        if name and (text.startswith('/me ') or text.startswith('/me\n')):
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -2362,7 +2362,7 @@ class Interface:
 | 
			
		|||
            if pixbuf is None:
 | 
			
		||||
                return
 | 
			
		||||
            if typ not in ('jpeg', 'png'):
 | 
			
		||||
                app.log.info('gtkpixbuf cannot save other than jpeg and '\
 | 
			
		||||
                log.info('gtkpixbuf cannot save other than jpeg and '\
 | 
			
		||||
                    'png formats. saving \'%s\' avatar as png file (originaly: %s)'\
 | 
			
		||||
                    % (jid, typ))
 | 
			
		||||
                typ = 'png'
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -31,6 +31,7 @@ import base64
 | 
			
		|||
import mimetypes
 | 
			
		||||
import os
 | 
			
		||||
import time
 | 
			
		||||
import logging
 | 
			
		||||
 | 
			
		||||
from gajim import gtkgui_helpers
 | 
			
		||||
from gajim import dialogs
 | 
			
		||||
| 
						 | 
				
			
			@ -39,6 +40,7 @@ from gajim import vcard
 | 
			
		|||
from gajim.common import app
 | 
			
		||||
from gajim.common import ged
 | 
			
		||||
 | 
			
		||||
log = logging.getLogger('gajim.profile')
 | 
			
		||||
 | 
			
		||||
class ProfileWindow:
 | 
			
		||||
    """
 | 
			
		||||
| 
						 | 
				
			
			@ -181,7 +183,7 @@ class ProfileWindow:
 | 
			
		|||
                try:
 | 
			
		||||
                    os.remove(path_to_file)
 | 
			
		||||
                except OSError:
 | 
			
		||||
                    app.log.debug('Cannot remove %s' % path_to_file)
 | 
			
		||||
                    log.debug('Cannot remove %s' % path_to_file)
 | 
			
		||||
 | 
			
		||||
        def on_clear(widget):
 | 
			
		||||
            self.dialog.destroy()
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		
		Reference in a new issue