On Thu, 5 Jan 2023 at 05:06, Barry Scott <ba...@barrys-emacs.org> wrote: > > > On 03/01/2023 21:24, c.bu...@posteo.jp wrote: > > Am 03.01.2023 17:51 schrieb r...@zedat.fu-berlin.de: > >> logging.getLogger().addHandler( logging.StreamHandler( sys.stdout )) > > > > But I don't want to make all log levels go to stdout. Just DEBUG and > > INFO. But this would be a workaround. > > > > The main question here is why does Python deciecded to make all logs > > go to stderr? > > Maybe I totally misunderstood the intention of logging.info()?! Isn't > > this the "usual applicaton output"? > > > > If not, what messages should go into logging.info()? Can you name me > > some examples? > > Example: > > write an app that prints the contents of a file. > > The application output is the contents of the file. > > The logging might be this when all is working: > > INFO About to open <filename> > INFO Wrote <number> bytes from <filename> > > The logging might be this when there is a problem: > > INFO About to open <filename> > ERROR Failed to open <filename> - <reason> > > Does that help?
Notably, the info lines can provide context for an error. For example: INFO: Loading module XYZ WARN: Unrecognized module option frobnicate=1 INFO: Using default spamination of 4 ERROR: Insufficient ham to spaminate This tells a hypothetical (but only slightly hypothetical) story of a module that was given an incorrect or misspelled option, and which then failed to load as a consequence. Without the INFO lines, it would be harder to figure out what the problem was, but they are still part of logging, not output, and belong in the same place as the warnings and errors. ChrisA -- https://mail.python.org/mailman/listinfo/python-list