code: def formatMessage(self, record: LogRecord) -> str:
      global _colorama_initialized
  
      if (
          "${" in record.message
      ):  # contains colorful text: "hello ${GREEN}world"
          if not _colorama_initialized:
              colorama.init()
              _colorama_initialized = True
          message = string.Template(record.message).safe_substitute(
              _colorful
          )
      else:
          message = record.message
  
      if record.levelno >= logging.ERROR:
          level = colorama.Fore.RED + "ERROR: "
      elif record.levelno >= logging.WARNING:
          level = colorama.Fore.YELLOW + "WARNING: "
      elif record.levelno >= logging.INFO:
          level = colorama.Fore.GREEN
      else:
          level = colorama.Fore.BLUE
  
      content = level + message + colorama.Style.RESET_ALL
      if record.levelno >= logging.INFO:
          return f"[{record.asctime}] {content}"
      elif record.threadName == "MainThread":
          return f"[{record.asctime}] {record.name} {content}"
      else:
          return f"[{record.asctime}] {record.threadName}:{record.name} {content}"
  
imports: from __future__ import annotations
  import logging
  import sys
  from datetime import datetime
  from io import TextIOBase
  from logging import FileHandler, Formatter, Handler, LogRecord, Logger, StreamHandler
  from pathlib import Path
  import string
  from typing import Optional
  import colorama
  from .env_vars import dispatcher_env_vars, trial_env_vars
label_desc: Use image node_id 2 for calling the _StdoutFormatter obj's underlying member method code with example usage: obj.formatMessage(record) and returns: str, record, str, content, str, record, str, record, str, content, str, record, str, record, str, record, str, content