class_docstr: Print and log messages while keeping track of time.
      
docstr: Print the time elapsed between the last call and the current
  call, with an optional message.
docstr_tok: ["Print","the","time","elapsed","between","the","last","call","and","the","current","call",",","with","an","optional","message","."]
code: def __call__(self, msg="", total=False):
      """Print the time elapsed between the last call and the current
      call, with an optional message.
      """
      if not total:
          time_lapse = time.time() - self.last_time
          full_msg = "%s: %s" % (msg, format_time(time_lapse))
      else:
          # FIXME: Too much logic duplicated
          time_lapse = time.time() - self.start_time
          full_msg = "%s: %.2fs, %.1f min" % (
              msg,
              time_lapse,
              time_lapse / 60,
          )
      print(full_msg, file=sys.stderr)
      if self.logfile is not None:
          try:
              with open(self.logfile, "a") as f:
                  print(full_msg, file=f)
          except:
              """Multiprocessing writing to files can create race
              conditions. Rather fail silently than crash the
              calculation.
              """
              # XXX: We actually need a debug flag to disable this
              # silent failure.
      self.last_time = time.time()
  
imports: from __future__ import print_function
  import time
  import sys
  import os
  import shutil
  import logging
  import pprint
  from .disk import mkdirp
label_desc: Use image node_id 2 for calling the PrintTime obj's underlying member method code with example usage: obj.__call__(msg, total) without return types