Commits

jordilin committed de7a260

refactored get current time to utils

Comments (0)

Files changed (2)

log4client/src/log4tailer/reporting.py

 # You should have received a copy of the GNU General Public License
 # along with Log4Tailer.  If not, see <http://www.gnu.org/licenses/>.
 
-from time import time, localtime, strftime
+from time import time
+from log4tailer import utils
 from log4tailer import TermColorCodes, Timer
 import datetime
 
         self.is_daemonized = False
         self.timer = Timer.Timer(self.gapTime)
         self.timer.startTimer()
+        self.report_file = None
 
     def add_notifier(self, notifier):
         self.notifiers.append(notifier)
 
     def flushReport(self):
-        for log,dictlog in self.logsReport.iteritems():
-            for key,val in dictlog.iteritems():
+        for _, dictlog in self.logsReport.iteritems():
+            for key, _ in dictlog.iteritems():
                 if key in ['ERROR', 'FATAL', 'CRITICAL', 'OTHERS']:
                     dictlog[key] = []
                 else:
                     dictlog[key] = 0
 
-    def __get_now(self):
-        return strftime("%d %b %Y %H:%M:%S", localtime())
-
     def update(self, message, log):
         messageLevel = message.messageLevel
         plainmessage, _ = message.getPlainMessage()
             if messageLevel in self.nonTimeStamped:
                 logKey[messageLevel] += 1
             else:
-                res = self.__get_now()
+                res = utils.get_now()
                 logKey[messageLevel].append(res +'=>> '+plainmessage)
         for notifier in self.notifiers:
             if notifier.alerted:
-                res = self.__get_now()
+                res = utils.get_now()
                 logKey['OTHERS'].append(res + '=>> '+ notifier.alerting_msg)
         self.report_now()
 

log4client/src/log4tailer/utils.py

 # You should have received a copy of the GNU General Public License
 # along with Log4Tailer.  If not, see <http://www.gnu.org/licenses/>.
 
-
+from time import localtime, strftime
 import getpass
 from log4tailer import notifications
 
     mailAction.connectSMTP()
     return mailAction
 
+def get_now():
+    return strftime("%d %b %Y %H:%M:%S", localtime())
 
+
+
+