[IPython-dev] iplogging suggestions added

Robert Kern robert.kern@gmail....
Sat Dec 11 16:37:15 CST 2010


On 2010-12-11 12:47 , Omar Andrés Zapata Mesa wrote:
> Hi all.
> All suggestion of Brian, Fernando and Mirnk was wrotte in the code.
> you can set optional colors, and default format too.
> https://github.com/omazapa/ipython/blob/iplogging/IPython/utils/iplogging.py
>
> ex1:
> In [1]: from iplogging import get_logger
> In [2]: kernel_logger=get_logger(name="kernel")
> In [3]: kernel_logger.debug("debug code here")
> LOGGER: kernel
> LEVEL: DEBUG
> PROCESS: 5352
> FILE: <ipython-input-3-39a714ce7396>
> LINE: 1
> MESSAGE: debug code here
>
> ex2:
>
> In [4]:
> frontend_logger=get_logger(name="frontend",format="%(name)s\n%(levelname)s\n%(message)s\n",use_color=True)
> In [3]: frontend_logger.debug("debug code here")
>
> output in http://gfifdev.udea.edu.co/IpythonLogging2.png
>
> Note that I put optional colors and format.
>
> Suggestions Please.

One should not add Handlers or Formatters inside the IPython library code.

http://docs.python.org/library/logging#configuring-logging-for-a-library

The only place one ought to add Handlers or Formatters (except for a 
NullHandler) is at the main() level.

-- 
Robert Kern

"I have come to believe that the whole world is an enigma, a harmless enigma
  that is made terrible by our own mad attempt to interpret it as though it had
  an underlying truth."
   -- Umberto Eco



More information about the IPython-dev mailing list