Rocksolid Light

Welcome to RetroBBS

mail  files  register  newsreader  groups  login

Message-ID:  

Play Rogue, visit exotic locations, meet strange creatures and kill them.


devel / comp.lang.python / Re: What should go to stdout/stderr and why Python logging write everything to stderr?

SubjectAuthor
o Re: What should go to stdout/stderr and why Python logging writeCameron Simpson

1
Re: What should go to stdout/stderr and why Python logging write everything to stderr?

<mailman.1382.1672781390.20444.python-list@python.org>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=25387&group=comp.lang.python#25387

  copy link   Newsgroups: comp.lang.python
Path: i2pn2.org!i2pn.org!news.swapon.de!fu-berlin.de!uni-berlin.de!not-for-mail
From: cs@cskk.id.au (Cameron Simpson)
Newsgroups: comp.lang.python
Subject: Re: What should go to stdout/stderr and why Python logging write
everything to stderr?
Date: Wed, 4 Jan 2023 08:29:39 +1100
Lines: 57
Message-ID: <mailman.1382.1672781390.20444.python-list@python.org>
References: <B448D1C0-8EF8-4BE1-B90B-331F34C7AF2A@damon-family.org>
<Y7SeQ6vxvXPEY1FP@cskk.homeip.net>
Mime-Version: 1.0
Content-Type: text/plain; charset=us-ascii; format=flowed
X-Trace: news.uni-berlin.de FDXHkP1S4ZlV+urZIGvGfwaZWvt+1yOmyL6BPfkP+Jhg==
Return-Path: <cameron@cskk.id.au>
X-Original-To: python-list@python.org
Delivered-To: python-list@mail.python.org
Authentication-Results: mail.python.org; dkim=none reason="no signature";
dkim-adsp=none (unprotected policy); dkim-atps=neutral
X-Spam-Status: OK 0.000
X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; "python's": 0.05; 'usage':
0.05; 'debug': 0.07; 'used.': 0.07; 'divide': 0.09; 'info,': 0.09;
'parse': 0.09; 'cheers,': 0.11; 'subject:Python': 0.12; 'log':
0.12; 'that.': 0.15; '(eg': 0.16; 'arguments': 0.16; 'cameron':
0.16; 'default.': 0.16; 'from:addr:cs': 0.16;
'from:addr:cskk.id.au': 0.16; 'from:name:cameron simpson': 0.16;
'goal.': 0.16; 'intention': 0.16; 'mandatory': 0.16; 'message-
id:@cskk.homeip.net': 0.16; 'pollute': 0.16; 'received:13.237':
0.16; 'received:13.237.201': 0.16; 'received:13.237.201.189':
0.16; 'received:cskk.id.au': 0.16; 'received:id.au': 0.16;
'received:l': 0.16; 'received:mail.cskk.id.au': 0.16; 'should,':
0.16; 'simpson': 0.16; 'stdout': 0.16; 'stdout.': 0.16; 'streams':
0.16; 'subject:logging': 0.16; 'wrote:': 0.16; 'python': 0.16;
'code.': 0.17; 'libraries': 0.19; 'to:addr:python-list': 0.20;
'version': 0.23; 'goal': 0.23; 'behavior': 0.26; 'solution.':
0.26; "isn't": 0.27; 'coming': 0.27; 'output': 0.28; 'goes': 0.28;
'error': 0.29; 'header:User-Agent:1': 0.30; 'am,': 0.31; 'modify':
0.31; 'module': 0.31; 'think': 0.32; "doesn't": 0.32; 'assume':
0.32; 'context': 0.32; 'to:name:python': 0.32; 'but': 0.32;
'there': 0.33; 'core': 0.34; 'header:In-Reply-To:1': 0.34;
'programme': 0.35; 'received:au': 0.35; 'request': 0.35; 'change':
0.36; 'those': 0.36; 'this.': 0.37; 'could': 0.38; 'two': 0.39;
'developers': 0.39; 'use': 0.39; 'subject:What': 0.40;
'something': 0.40; 'should': 0.40; 'me.': 0.62; 'between': 0.63;
'everything': 0.63; 'down': 0.64; 'received:13': 0.64; 'your':
0.64; 'produce': 0.65; 'received:userid': 0.66; 'decided': 0.67;
'technical': 0.67; 'decision': 0.68; 'matter': 0.68; 'lot.': 0.84;
'merely': 0.84; 'subject: \n ': 0.84; 'sure.': 0.84; 'affect':
0.91
Mail-Followup-To: Python <python-list@python.org>
Content-Disposition: inline
In-Reply-To: <B448D1C0-8EF8-4BE1-B90B-331F34C7AF2A@damon-family.org>
User-Agent: Mutt/2.2.7 (2022-08-07)
X-BeenThere: python-list@python.org
X-Mailman-Version: 2.1.39
Precedence: list
List-Id: General discussion list for the Python programming language
<python-list.python.org>
List-Unsubscribe: <https://mail.python.org/mailman/options/python-list>,
<mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive: <https://mail.python.org/pipermail/python-list/>
List-Post: <mailto:python-list@python.org>
List-Help: <mailto:python-list-request@python.org?subject=help>
List-Subscribe: <https://mail.python.org/mailman/listinfo/python-list>,
<mailto:python-list-request@python.org?subject=subscribe>
X-Mailman-Original-Message-ID: <Y7SeQ6vxvXPEY1FP@cskk.homeip.net>
X-Mailman-Original-References: <B448D1C0-8EF8-4BE1-B90B-331F34C7AF2A@damon-family.org>
 by: Cameron Simpson - Tue, 3 Jan 2023 21:29 UTC

On Jan 3, 2023, at 10:38 AM, c.buhtz@posteo.jp wrote:
>> this posting isn't about asking for a technical solution. My
>> intention is to understand the design decision Python's core developers made in
>> context of that topic.
>>
>> The logging module write everything to stderr no matter which logging
>> level is used.

Sure. They're logs.

>> The argparse module does it more differentiated. If arguments are
>> mandatory but none are given then argparse produce a short version of
>> the usage info; on stderr. If the user request the usage info via "-h"
>> it goes to stdout. This is the behavior I would expect.

Error messages to stderr. _Requested output_ to stdout. Good with me.

>> Why does logging behave different? DEBUG and INFO imho should go to
>> stdout not stderr.

I entirely disagree.

Consider a shell pipeline:

cmd1 | cmd2 | cmd3

where `cmd2` and `cmd3` parse data coming down the pipes. Letting
logging info into those data streams would produce garbage. This
separation between core programme output and error/logging output is the
basic reason that the two streams exist, and the reason logging goes to
stderr by default.

You're conflating "normal output" with INFO, which is not a substitute
for eg `print()`.

>> Of course I could modify the handlers etc. to workaround this. But I
>> assume that there was something in mind of the Python developers when
>> they decided that.

Basicly, logging data is not the normal output. So it does not get sent
to stdout. The log level doesn't change that characteristic.

>> My goal is not to divide between the use of print() or logging.info()
>> in my own code. This would mess up a lot.

I think you should, or you should fiddle the handlers as you previous
resist doing if it is your goal.

But keep in mind that if you do that globally (eg in the root logger) it
will affect _all_ logging calls, not merely your own, and other
libraries will assume they can log at whatever level and not pollute
stdout with their logs.

Basicly, logging isn't "output".

Cheers,
Cameron Simpson <cs@cskk.id.au>


devel / comp.lang.python / Re: What should go to stdout/stderr and why Python logging write everything to stderr?

1
server_pubkey.txt

rocksolid light 0.9.81
clearnet tor