Skip to content

Commit

Permalink
fix the Formatter and some deep TODO thinking
Browse files Browse the repository at this point in the history
  • Loading branch information
mahmoud committed Feb 9, 2016
1 parent fc9189e commit f16eea5
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 28 deletions.
4 changes: 4 additions & 0 deletions TODO.rst
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
TODO
====

* Need to get rid of statefulness if async-through-Logger is going to
work (or otherwise separate begin/end messages)
* Level remapping

* Dynamic (as in scope) transaction association (parent ID)
* Parser from Formatter
* "auto" mode for escaping (eliminate excessive quoting)
Expand Down
34 changes: 6 additions & 28 deletions lithoxyl/formatters.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,12 +82,13 @@ def __init__(self, format_str,
else:
self.quoter = quoter or self._default_quoter
if not callable(self.quoter):
raise TypeError('expected callable for Formatter.quoter, not %r'
% self.quoter)
raise TypeError('expected callable or False for Formatter.quoter,'
' not %r' % self.quoter)

# NOTE: making this copy will be detrimental to a Formatter cache
extra_field_map = dict([(f.fname, f) for f in extra_fields or []])
self._field_map = dict(BUILTIN_FIELD_MAP, **extra_field_map)
self._field_map = dict(BUILTIN_FIELD_MAP)
if extra_fields:
extra_field_map = dict([(f.fname, f) for f in extra_fields or []])
self._field_map.update(extra_field_map)
self._getter_map = dict([(f.fname, f.getter)
for f in self._field_map.values()])

Expand Down Expand Up @@ -160,29 +161,6 @@ def _default_quoter(self, token):
__call__ = format_record


"""
class Formatter(object):
def __init__(self, format_str, on_err=None):
# TODO: check that templette complies with reversability
# requirements
# TODO: check field type compatibilty when
# default format specs have been overridden for built-in
# format fields
def format_record(self, record):
try:
return self.templette.format_record(record)
except Exception:
# TODO: basically impossible atm, but eventually log to
# stderr or something
raise
__call__ = format_record
def __repr__(self):
return '%s(%r)' % (self.__class__.__name__, self._format_str)
"""

"""
reversability requirements:
Expand Down

0 comments on commit f16eea5

Please sign in to comment.