I want to have my logging.info
show in the terminal/screen in the Python debugger (pdb) and on file. However, it does not appear on the screen. It works in a seperate python console just fine. Why does it not work in pdb? See:
bot@18f71e53b3f5:~/pycoq/tutorial$ python brandos_pycoq_tutorial.py
> /home/bot/pycoq/tutorial/brandos_pycoq_tutorial.py(142)<module>()
-> main()
(Pdb) import logging
(Pdb)
(Pdb) level = logging.INFO
(Pdb) format = ' %(message)s'
(Pdb) handlers = [logging.FileHandler('./filename.log'), logging.StreamHandler()]
(Pdb)
(Pdb) logging.basicConfig(level = level, format = format, handlers = handlers)
(Pdb) logging.info('Hey, this is working!')
(Pdb) --KeyboardInterrupt--
(Pdb)
works in console:
bot@18f71e53b3f5:~/pycoq/tutorial$ python
Python 3.9.12 (main, Jun 1 2022, 11:38:51)
[GCC 7.5.0] :: Anaconda, Inc. on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import logging
>>>
>>> level = logging.INFO
>>> format = ' %(message)s'
>>> handlers = [logging.FileHandler('./filename.log'), logging.StreamHandler()]
>>>
>>> logging.basicConfig(level = level, format = format, handlers = handlers)
>>> logging.info('Hey, this is working!')
Hey, this is working!
>>>
KeyboardInterrupt
>>>
the level is set right as refered here: Printing to screen and writing to a file at the same time