how to capture and log to console using CapturingLoggerFactory

I'm struggling to figure out how to use CapturingLoggerFactory for my unit test so that I can capture the log and assert on them but also to actually log the information to the console. CapturingLoggerFactory class doesn't log anything, just adds the logs to the list that you can later on assert on.

My example code:

class MyClass():
  def __init__(self): = CapturingLoggerFactory()
    configure(, processors=[JSONRenderer()])
    self.logger = get_logger()"MyClass instantiated")

Now in my tests I have something like this:

def test_log(self) -> None:
  my_class = MyClass()
  self.assertEqual([-1].method_name, "info")
  log_message = json.loads([-1].args[0])["event"]
  self.assertEqual(log_message, "MyClass instantiated")

Now this all works perfectly fine but the actual log "MyClass instantiated" is never printed on the console.

Anyone knows how to print and capture this log?

How many English words
do you know?
Test your English vocabulary size, and measure
how many words do you know
Online Test
Powered by Examplum