code: def test_setup_logger(capsys, dirname):
      trainer = Engine(lambda e, b: None)
      evaluator = Engine(lambda e, b: None)
  
      assert len(trainer.logger.handlers) == 0
      trainer.logger.addHandler(logging.NullHandler())
      trainer.logger.addHandler(logging.NullHandler())
      trainer.logger.addHandler(logging.NullHandler())
  
      fp = dirname / "log"
  
      def _test(stream):
          trainer.logger = setup_logger(
              "trainer", stream=stream, filepath=fp, reset=True
          )
          evaluator.logger = setup_logger(
              "evaluator", stream=stream, filepath=fp, reset=True
          )
  
          assert len(trainer.logger.handlers) == 2
          assert len(evaluator.logger.handlers) == 2
  
          @trainer.on(Events.EPOCH_COMPLETED)
          def _(_):
              evaluator.run([0, 1, 2])
  
          trainer.run([0, 1, 2, 3, 4, 5], max_epochs=5)
  
          captured = capsys.readouterr()
          if stream is sys.stdout:
              err = captured.out.split("\n")
          else:
              err = captured.err.split("\n")
  
          with open(fp, "r") as h:
              data = h.readlines()
  
          for source in [err, data]:
              assert (
                  "trainer INFO: Engine run starting with max_epochs=5."
                  in source[0]
              )
              assert (
                  "evaluator INFO: Engine run starting with max_epochs=1."
                  in source[1]
              )
  
      _test(stream=None)
      _test(stream=sys.stderr)
      _test(stream=sys.stdout)
  
      # Needed by windows to release FileHandler in the loggers
      logging.shutdown()
  
file_path: ignite/tests/ignite/test_utils.py
imports: import logging
  import sys
  from collections import namedtuple
  import pytest
  import torch
  from packaging.version import Version
  from ignite.engine import Engine, Events
  from ignite.utils import convert_tensor, deprecated, hash_checkpoint, setup_logger, to_onehot
label_desc: Use image node_id 4 for calling a global function with example usage: test_setup_logger(capsys, dirname) without return types