Skip to content

Commit

Permalink
Merge pull request #22 from iheartradio/app-logger
Browse files Browse the repository at this point in the history
Replace Henson's logger
  • Loading branch information
jonafato committed Mar 8, 2016
2 parents 19c2d98 + 52192bc commit 5e841a2
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 8 deletions.
2 changes: 1 addition & 1 deletion CHANGES.rst
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Version 0.3.0
=============

Release TBD
- Replace Henson's logger with the instance of ``Logging``


Version 0.2.0
Expand Down
8 changes: 4 additions & 4 deletions docs/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@ Quickstart
from henson import Application
from henson_logging import Logging
logger = Logging()
app = Application(__name__, logger=logger)
logger.init_app(app)
app = Application(__name__)
logger = Logging(app)
.. todo:: Fix this API. It's awkward.
In addition to giving you a logger that can be used throughout your
application, it will replace Henson's internal logger with the new one.

Configuration
=============
Expand Down
7 changes: 4 additions & 3 deletions henson_logging/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,17 +62,19 @@ class Logging(Extension):

def __init__(self, app=None):
"""Initialize the instance."""
self._logger = None

super().__init__(app)

self._logger = None
app.logger = self

critical = lambda s, *a, **kw: s.logger.critical(*a, **kw)
debug = lambda s, *a, **kw: s.logger.debug(*a, **kw)
error = lambda s, *a, **kw: s.logger.error(*a, **kw)
info = lambda s, *a, **kw: s.logger.info(*a, **kw)
exception = lambda s, *a, **kw: s.logger.exception(*a, **kw)
fatal = lambda s, *a, **kw: s.logger.fatal(*a, **kw)
log = lambda s, *a, **kw: s.logger.log(*a, **kw)
setLevel = lambda s, l: s.logger.setLevel(l)
warning = lambda s, *a, **kw: s.logger.warning(*a, **kw)

@property
Expand All @@ -83,7 +85,6 @@ def logger(self):
logging.RootLogger: The logger.
"""
if not self._logger:

settings = {
'version': self.app.settings['LOG_VERSION'],
'formatters': {
Expand Down

0 comments on commit 5e841a2

Please sign in to comment.