class_docstr: Print and log messages while keeping track of time.
      
code: def __init__(self, logfile=None, logdir=None):
      if logfile is not None and logdir is not None:
          raise ValueError("Cannot specify both logfile and logdir")
      # XXX: Need argument docstring
      self.last_time = time.time()
      self.start_time = self.last_time
      if logdir is not None:
          logfile = os.path.join(logdir, "joblib.log")
      self.logfile = logfile
      if logfile is not None:
          mkdirp(os.path.dirname(logfile))
          if os.path.exists(logfile):
              # Rotate the logs
              for i in range(1, 9):
                  try:
                      shutil.move(
                          logfile + ".%i" % i, logfile + ".%i" % (i + 1)
                      )
                  except:  # noqa: E722
                      "No reason failing here"
              # Use a copy rather than a move, so that a process
              # monitoring this file does not get lost.
              try:
                  shutil.copy(logfile, logfile + ".1")
              except:  # noqa: E722
                  "No reason failing here"
          try:
              with open(logfile, "w") as logfile:
                  logfile.write("\nLogging joblib python script\n")
                  logfile.write(
                      "\n---%s---\n" % time.ctime(self.last_time)
                  )
          except:  # noqa: E722
              """Multiprocessing writing to files can create race
              conditions. Rather fail silently than crash the
              computation.
              """
  
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 1 to create a new PrintTime object from inherited base classes: object with example: obj = PrintTime(logfile, logdir)