## @file helpers.py
## @brief Miscellaneous helper functions
##
## Detailed description (for Doxygen goes here)

"""
Miscellaneous helper functions

Detailed description (for [e]pydoc goes here)
"""


import datetime

def Log(msg):
   """
   Prints a formatted log message to stdout.

   @type  msg   : str
   @param msg   : Message to log
   @rtype       : None
   """

   print("[ " + str(datetime.datetime.now()) + " ]" + msg)

##
## @brief Measures elapsed time between two points.
##
class StopWatch:
   """
   Measures elapsed time between two points.
   """

   def __init__(self):
      self.start = datetime.datetime.now()

   def finish(self, msg):
      self.end = datetime.datetime.now()
      self.timeTaken = self.end - self.start
      Log("Time taken for " + msg + " : " + str(self.timeTaken))
