Skip to content

Commit

Permalink
Add logging capability
Browse files Browse the repository at this point in the history
  • Loading branch information
hirschmann committed Jan 20, 2017
1 parent 4646451 commit 217f3b1
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions brewapp/base/tempfilter.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
import logging
from collections import deque


class TemperatureFilter(object):

def __init__(self, maxViableDeviation=4):
self._logger = logging.getLogger(type(self).__name__)
self.__deque = deque(maxlen=5)
self.__maxViableDeviation = maxViableDeviation
self.__lastKnownGood = 0
Expand All @@ -13,9 +15,9 @@ def filterTemperature(self, temperature):
median = sorted(self.__deque)[len(self.__deque)//2]
deviation = abs(median - temperature)

print("deq:" + str(self.__deque))
print("med:" + str(median))
print("dev:" + str(deviation))
self._logger.debug("deq: " + str(self.__deque))
self._logger.debug("med: " + str(median))
self._logger.debug("dev: " + str(deviation))

if deviation > self.__maxViableDeviation:
return self.__lastKnownGood
Expand Down

0 comments on commit 217f3b1

Please sign in to comment.