class_docstr: A Logfile class with different policies for file creation
class_docstr_tok: ["A","Logfile","class","with","different","policies","for","file","creation"]
docstr: Generate a new log-file with a default header.
  
  Raises RuntimeError if the log has already been started
docstr_tok: ["Generate","a","new","log-file","with","a","default","header",".","Raises","RuntimeError","if","the","log","has","already","been","started"]
code: def logstart(
      self,
      logfname=None,
      loghead=None,
      logmode=None,
      log_output=False,
      timestamp=False,
      log_raw_input=False,
  ):
      """Generate a new log-file with a default header.
  
      Raises RuntimeError if the log has already been started"""
  
      if self.logfile is not None:
          raise RuntimeError(
              "Log file is already active: %s" % self.logfname
          )
  
      # The parameters can override constructor defaults
      if logfname is not None:
          self.logfname = logfname
      if loghead is not None:
          self.loghead = loghead
      if logmode is not None:
          self.logmode = logmode
  
      # Parameters not part of the constructor
      self.timestamp = timestamp
      self.log_output = log_output
      self.log_raw_input = log_raw_input
  
      # init depending on the log mode requested
      isfile = os.path.isfile
      logmode = self.logmode
  
      if logmode == "append":
          self.logfile = io.open(self.logfname, "a", encoding="utf-8")
  
      elif logmode == "backup":
          if isfile(self.logfname):
              backup_logname = self.logfname + "~"
              # Manually remove any old backup, since os.rename may fail
              # under Windows.
              if isfile(backup_logname):
                  os.remove(backup_logname)
              os.rename(self.logfname, backup_logname)
          self.logfile = io.open(self.logfname, "w", encoding="utf-8")
  
      elif logmode == "global":
          self.logfname = os.path.join(self.home_dir, self.logfname)
          self.logfile = io.open(self.logfname, "a", encoding="utf-8")
  
      elif logmode == "over":
          if isfile(self.logfname):
              os.remove(self.logfname)
          self.logfile = io.open(self.logfname, "w", encoding="utf-8")
  
      elif logmode == "rotate":
          if isfile(self.logfname):
              if isfile(self.logfname + ".001~"):
                  old = glob.glob(self.logfname + ".*~")
                  old.sort()
                  old.reverse()
                  for f in old:
                      root, ext = os.path.splitext(f)
                      num = int(ext[1:-1]) + 1
                      os.rename(
                          f, root + "." + repr(num).zfill(3) + "~"
                      )
              os.rename(self.logfname, self.logfname + ".001~")
          self.logfile = io.open(self.logfname, "w", encoding="utf-8")
  
      if logmode != "append":
          self.logfile.write(self.loghead)
  
      self.logfile.flush()
      self.log_active = True
  
file_path: catboost/contrib/python/ipython/py3/IPython/core/logger.py
imports: import glob
  import io
  import logging
  import os
  import time
label_desc: Use image node_id 4 for calling the Logger obj's underlying member method code with example usage: obj.logstart(logfname, loghead, logmode, log_output, timestamp, log_raw_input) without return types