class_docstr: Logs the results of an attack to a file, or `stdout`.
class_docstr_tok: ["Logs","the","results","of","an","attack","to","a","file",",","or","`","stdout","`","."]
code: def __init__(self, filename="", stdout=False, color_method="ansi"):
      self.stdout = stdout
      self.filename = filename
      self.color_method = color_method
      if stdout:
          self.fout = sys.stdout
      elif isinstance(filename, str):
          directory = os.path.dirname(filename)
          directory = directory if directory else "."
          if not os.path.exists(directory):
              os.makedirs(directory)
          self.fout = open(filename, "w")
          logger.info(f"Logging to text file at path {filename}")
      else:
          self.fout = filename
      self.num_results = 0
  
file_path: TextAttack/textattack/loggers/file_logger.py
imports: import os
  import sys
  import terminaltables
  from textattack.shared import logger
  from .logger import Logger
label_desc: Use image node_id 1 to create a new FileLogger object from inherited base classes: Logger with example: obj = FileLogger(filename, stdout, color_method)