diff options
| author | Brianna | 2017-08-10 16:16:07 -0400 |
|---|---|---|
| committer | GitHub | 2017-08-10 16:16:07 -0400 |
| commit | c5a0c9b364f6d6228a3027b5668915a838c1ba95 (patch) | |
| tree | f04e4117c133a539a87ffcae00d0cd66fa1517f4 /src/component.py | |
| parent | 2603c639254d8ab8e87e201613d123da367cae21 (diff) | |
| parent | 1c4afc96d69789f16284c067ffd7098dc7b2ca70 (diff) | |
Merge pull request #55 from djfun/logging
using the builtin logging module
Diffstat (limited to 'src/component.py')
| -rw-r--r-- | src/component.py | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/src/component.py b/src/component.py index 5b6f9a7..a1e24db 100644 --- a/src/component.py +++ b/src/component.py @@ -8,6 +8,7 @@ import os import sys import math import time +import logging from toolkit.frame import BlankFrame from toolkit import ( @@ -15,6 +16,9 @@ from toolkit import ( ) +log = logging.getLogger('AVP.ComponentHandler') + + class ComponentMetaclass(type(QtCore.QObject)): ''' Checks the validity of each Component class and mutates some attrs. @@ -135,17 +139,17 @@ class ComponentMetaclass(type(QtCore.QObject)): # Turn version string into a number try: if 'version' not in attrs: - print( + log.error( 'No version attribute in %s. Defaulting to 1' % attrs['name']) attrs['version'] = 1 else: attrs['version'] = int(attrs['version'].split('.')[0]) except ValueError: - print('%s component has an invalid version string:\n%s' % ( + log.critical('%s component has an invalid version string:\n%s' % ( attrs['name'], str(attrs['version']))) except KeyError: - print('%s component has no version string.' % attrs['name']) + log.critical('%s component has no version string.' % attrs['name']) else: return super().__new__(cls, name, parents, attrs) quit(1) @@ -546,6 +550,8 @@ class Component(QtCore.QObject, metaclass=ComponentMetaclass): and oldRelativeVal != newRelativeVal: # Float changed without pixel value changing, which # means the pixel value needs to be updated + log.debug('Updating %s #%s\'s relative widget: %s' % ( + self.name, self.compPos, attr)) self._trackedWidgets[attr].blockSignals(True) self.updateRelativeWidgetMaximum(attr) pixelVal = self.pixelValForAttr(attr, oldRelativeVal) @@ -576,7 +582,7 @@ class ComponentError(RuntimeError): msg = str(sys.exc_info()[1]) else: msg = 'Unknown error.' - print("##### ComponentError by %s's %s: %s" % ( + log.error("ComponentError by %s's %s: %s" % ( caller.name, name, msg)) # Don't create multiple windows for quickly repeated messages |
