code: def test_log():
      # Stack containing one non-matching object
      with capture_output() as out:
          t = Run3()
          t.run3()
      assert (
          out[0] == "[Run3.run3] method Test3\n[run] function run()\n"
      )
  
      # Stack containing two matching objects
      with capture_output() as out:
          t = Run2()
          t.run2()
      assert (
          out[0] == "[Run2.run2] method Test2\n"
          "[Run2.run2] method Test\n"
          "[Run2.run2] function run()\n"
      )
  
      # Stack containing one matching object
      with capture_output() as out:
          t = Run()
          t.run()
      assert (
          out[0] == "[Run.run] method Test\n[Run.run] function run()\n"
      )
  
      # Stack containing no object
      with capture_output() as out:
          run()
      assert out[0] == "[run] function run()\n"
  
      # Test stack_level too large
      with capture_output() as out:
          other_run()
      assert out[0] == "[<top_level>] function other_run()\n"
  
file_path: nilearn/nilearn/_utils/tests/test_logger.py
imports: import contextlib
  from sklearn.base import BaseEstimator
  from nilearn._utils.logger import log
label_desc: Use image node_id 4 for calling a global function with example usage: test_log() without return types