class_docstr: A base class providing the backwards-compatible spawn API for Pexpect.
  
  This should not be instantiated directly: use :class:`pexpect.spawn` or
  :class:`pexpect.fdpexpect.fdspawn`.
code: def _log(self, s, direction):
      if self.logfile is not None:
          self.logfile.write(s)
          self.logfile.flush()
      second_log = (
          self.logfile_send
          if (direction == "send")
          else self.logfile_read
      )
      if second_log is not None:
          second_log.write(s)
          second_log.flush()
  
imports: from io import StringIO, BytesIO
  import codecs
  import os
  import sys
  import re
  import errno
  from .exceptions import ExceptionPexpect, EOF, TIMEOUT
  from .expect import Expecter, searcher_string, searcher_re
label_desc: Use image node_id 2 for calling the SpawnBase obj's underlying member method code with example usage: obj._log(s, direction) without return types