Skip to content

Commit

Permalink
Tidy up logging
Browse files Browse the repository at this point in the history
  • Loading branch information
evanunderscore committed Feb 10, 2016
1 parent 5bbb0a1 commit 9e09758
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 8 deletions.
3 changes: 2 additions & 1 deletion CHANGELOG.rst
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
Changelog
=========

0.3.0 (2016-02-??)
0.3.0 (2016-02-10)
------------------

* Added support for Python 2.7
* Fixed code that was polluting the logging module's root logger

0.2.0 (2016-02-09)
------------------
Expand Down
14 changes: 7 additions & 7 deletions defopt.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
import funcsigs
inspect.signature = funcsigs.signature

logging.basicConfig()
log = logging.getLogger(__name__)

Doc = namedtuple('Doc', ('text', 'params'))
Param = namedtuple('Param', ('text', 'type'))
Expand Down Expand Up @@ -208,17 +208,17 @@ def _parse_doc(func):
elif len(parts) == 3:
doctype, type_, name = parts
if doctype != 'param':
logging.debug('ignoring field %s', field_name.text)
log.debug('ignoring field %s', field_name.text)
continue
logging.debug('inline param type %s', type_)
log.debug('inline param type %s', type_)
if 'type' in params[name]:
raise ValueError('type defined twice for {}'.format(name))
params[name]['type'] = type_
else:
logging.debug('ignoring field %s', field_name.text)
log.debug('ignoring field %s', field_name.text)
continue
text = ''.join(field_body.itertext())
logging.debug('%s %s: %s', doctype, name, text)
log.debug('%s %s: %s', doctype, name, text)
if doctype in params[name]:
raise ValueError('{} defined twice for {}'.format(doctype, name))
params[name][doctype] = text
Expand All @@ -241,7 +241,7 @@ def _evaluate(name, stack_depth=None):
If unspecified, `name` is assumed to refer to a builtin.
:type stack_depth: int
"""
logging.debug('evaluating %s', name)
log.debug('evaluating %s', name)
things = dict(vars(builtins))
if stack_depth is not None:
things.update(inspect.stack()[stack_depth + 1][0].f_locals)
Expand All @@ -251,7 +251,7 @@ def _evaluate(name, stack_depth=None):
for part in parts[1:]:
things = vars(thing)
thing = things[part]
logging.debug('evaluated to %r', thing)
log.debug('evaluated to %r', thing)
return thing


Expand Down

0 comments on commit 9e09758

Please sign in to comment.