summaryrefslogtreecommitdiff
path: root/factory/base.py
diff options
context:
space:
mode:
authorRaphaël Barrois <raphael.barrois@polytechnique.org>2013-04-12 00:14:33 +0200
committerRaphaël Barrois <raphael.barrois@polytechnique.org>2013-06-14 01:10:04 +0200
commit2cb136cfb8ef1d4b3a2cb68c4cbc23547bfc395f (patch)
tree9dc7cc3e9e56488326899feb37f612161969159a /factory/base.py
parenta4460de7719eb8c8bb1f3aa72b2ce233b45d9a87 (diff)
downloadfactory-boy-2cb136cfb8ef1d4b3a2cb68c4cbc23547bfc395f.tar
factory-boy-2cb136cfb8ef1d4b3a2cb68c4cbc23547bfc395f.tar.gz
Add logging calls (Closes #45).
Diffstat (limited to 'factory/base.py')
-rw-r--r--factory/base.py18
1 files changed, 17 insertions, 1 deletions
diff --git a/factory/base.py b/factory/base.py
index ff5404f..60aa218 100644
--- a/factory/base.py
+++ b/factory/base.py
@@ -20,7 +20,12 @@
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
# THE SOFTWARE.
+import logging
+
from . import containers
+from . import utils
+
+logger = logging.getLogger('factory.generate')
# Strategies
BUILD_STRATEGY = 'build'
@@ -300,7 +305,13 @@ class BaseFactory(object):
force_sequence = None
if extra:
force_sequence = extra.pop('__sequence', None)
- return containers.AttributeBuilder(cls, extra).build(
+ log_ctx = '%s.%s' % (cls.__module__, cls.__name__)
+ logger.debug('BaseFactory: Preparing %s.%s(extra=%r)',
+ cls.__module__,
+ cls.__name__,
+ extra,
+ )
+ return containers.AttributeBuilder(cls, extra, log_ctx=log_ctx).build(
create=create,
force_sequence=force_sequence,
)
@@ -338,6 +349,11 @@ class BaseFactory(object):
# Extract *args from **kwargs
args = tuple(kwargs.pop(key) for key in cls.FACTORY_ARG_PARAMETERS)
+ logger.debug('BaseFactory: Generating %s.%s(%s)',
+ cls.__module__,
+ cls.__name__,
+ utils.log_pprint(args, kwargs),
+ )
if create:
return cls._create(target_class, *args, **kwargs)
else: