class_docstr: This is a distributed event logger class essentially based on :class:`logging`.
  
  Args:
      name (str): The name of the logger.
  
  Note:
      The parallel_mode used in ``info``, ``warning``, ``debug`` and ``error``
      should be concluded in ``ParallelMode``. More details about ``ParallelMode`` could be found
      in `parallel_mode <https://github.com/hpcaitech/ColossalAI/blob/main/colossalai/context/parallel_mode.py>`_.
class_docstr_tok: ["This","is","a","distributed","event","logger","class","essentially","based","on",":","class",":","`","logging","`",".","Args",":","name","(","str",")",":","The","name","of","the","logger",".","Note",":","The","parallel_mode","used","in","``","info","``",",","``","warning","``",",","``","debug","``","and","``","error","``","should","be","concluded","in","``","ParallelMode","``",".","More","details","about","``","ParallelMode","``","could","be","found","in","`","parallel_mode","<","https",":","\/\/github.com\/hpcaitech\/ColossalAI\/blob\/main\/colossalai\/context\/parallel_mode.py",">","`","_","."]
docstr: Save the logs to file
  
  Args:
      path (A string or pathlib.Path object): The file to save the log.
      mode (str): The mode to write log into the file.
      level (str): Can only be INFO, DEBUG, WARNING and ERROR.
      suffix (str): The suffix string of log's name.
docstr_tok: ["Save","the","logs","to","file","Args",":","path","(","A","string","or","pathlib.Path","object",")",":","The","file","to","save","the","log",".","mode","(","str",")",":","The","mode","to","write","log","into","the","file",".","level","(","str",")",":","Can","only","be","INFO",",","DEBUG",",","WARNING","and","ERROR",".","suffix","(","str",")",":","The","suffix","string","of","log","'s","name","."]
code: def log_to_file(
      self,
      path: Union[str, Path],
      mode: str = "a",
      level: str = "INFO",
      suffix: str = None,
  ) -> None:
      """Save the logs to file
  
      Args:
          path (A string or pathlib.Path object): The file to save the log.
          mode (str): The mode to write log into the file.
          level (str): Can only be INFO, DEBUG, WARNING and ERROR.
          suffix (str): The suffix string of log's name.
      """
      assert isinstance(
          path, (str, Path)
      ), f"expected argument path to be type str or Path, but got {type(path)}"
      self._check_valid_logging_level(level)
  
      if isinstance(path, str):
          path = Path(path)
  
      # create log directory
      path.mkdir(parents=True, exist_ok=True)
  
      if suffix is not None:
          log_file_name = f"rank_{self.rank}_{suffix}.log"
      else:
          log_file_name = f"rank_{self.rank}.log"
      path = path.joinpath(log_file_name)
  
      # add file handler
      file_handler = logging.FileHandler(path, mode)
      file_handler.setLevel(getattr(logging, level))
      formatter = logging.Formatter(
          "colossalai - %(name)s - %(levelname)s: %(message)s"
      )
      file_handler.setFormatter(formatter)
      self._logger.addHandler(file_handler)
  
file_path: colossalai/colossalai/logging/logger.py
imports: import inspect
  import logging
  from pathlib import Path
  from typing import List, Union
  import torch.distributed
label_desc: Use image node_id 6 for calling the DistributedLogger obj's underlying member method code with example usage: obj.log_to_file(path, mode, level, suffix) without return types