Rocksolid Light

Welcome to novaBBS (click a section below)

mail  files  register  newsreader  groups  login

Message-ID:  

The system will be down for 10 days for preventive maintenance.


devel / comp.lang.python / Re: Neither pdb or print() displays the bug

SubjectAuthor
o Re: Neither pdb or print() displays the bugEthan Furman

1
Re: Neither pdb or print() displays the bug

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

  copy mid

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

  copy link   Newsgroups: comp.lang.python
Path: i2pn2.org!i2pn.org!news.swapon.de!fu-berlin.de!uni-berlin.de!not-for-mail
From: eth...@stoneleaf.us (Ethan Furman)
Newsgroups: comp.lang.python
Subject: Re: Neither pdb or print() displays the bug
Date: Tue, 1 Jun 2021 14:07:15 -0700
Lines: 36
Message-ID: <mailman.488.1622581638.3087.python-list@python.org>
References: <alpine.LNX.2.20.2106011309580.25401@salmo.appl-ecosys.com>
<20cb1a4f-ec85-9ea0-effe-b916f8be5a23@stoneleaf.us>
<alpine.LNX.2.20.2106011339300.25401@salmo.appl-ecosys.com>
<0343b334-2e10-f055-896b-b3ef9d080401@stoneleaf.us>
Mime-Version: 1.0
Content-Type: text/plain; charset=utf-8; format=flowed
Content-Transfer-Encoding: 7bit
X-Trace: news.uni-berlin.de MQzUCKDqSiOl9kWf8/WblAx2WF5//HSqVGhvby80tMcA==
Return-Path: <ethan@stoneleaf.us>
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.002
X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; "python's": 0.05;
'converting': 0.09; 'info,': 0.09; 'obviously': 0.09; 'output:':
0.09; 'subject:bug': 0.09; 'import': 0.14; 'from:addr:ethan':
0.16; 'from:addr:stoneleaf.us': 0.16; 'from:name:ethan furman':
0.16; 'message-id:@stoneleaf.us': 0.16;
'received:fractal.stoneleaf.us': 0.16; 'received:stoneleaf.us':
0.16; 'shepard': 0.16; 'subject:() ': 0.16; 'virtualenv': 0.16;
'~ethan~': 0.16; 'wrote:': 0.16; 'python': 0.16; 'pm,': 0.20;
'to:addr:python-list': 0.23; 'actual': 0.24; 'run': 0.24; 'code':
0.24; "i'll": 0.28; 'header:User-Agent:1': 0.31; 'it,': 0.31;
'but': 0.31; 'skip:_ 30': 0.32; "i'm": 0.32; "skip:' 40": 0.32;
'program': 0.33; 'using': 0.33; 'header:In-Reply-To:1': 0.33;
'well,': 0.35; 'code:': 0.35; 'two': 0.37; 'skip:w 10': 0.61;
'skip:b 10': 0.62; 'received:us': 0.65; 'del': 0.71; 'skip:f 20':
0.76; 'expert,': 0.84; 'spam)': 0.84
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101
Thunderbird/68.10.0
In-Reply-To: <alpine.LNX.2.20.2106011339300.25401@salmo.appl-ecosys.com>
Content-Language: en-US
X-BeenThere: python-list@python.org
X-Mailman-Version: 2.1.34
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: <0343b334-2e10-f055-896b-b3ef9d080401@stoneleaf.us>
X-Mailman-Original-References: <alpine.LNX.2.20.2106011309580.25401@salmo.appl-ecosys.com>
<20cb1a4f-ec85-9ea0-effe-b916f8be5a23@stoneleaf.us>
<alpine.LNX.2.20.2106011339300.25401@salmo.appl-ecosys.com>
 by: Ethan Furman - Tue, 1 Jun 2021 21:07 UTC

On 6/1/21 1:42 PM, Rich Shepard wrote:

> When I run it this is the output:
> $ python activitytypes.py 2021-06-01 13:39:10,219 -DEBUG - Start of Program
> 2021-06-01 13:39:15,229 -DEBUG - End of Program

Well, you only had two logging statements in that code -- logging is like print: if you want to see it, you have to call it:

logging.info('start of xx procedure')
logging.info('spam = %s', spam) # note the comma and not actual %-interpolation

> Obviously I have much to learn about using python's logging capabilities.
> I'll keep looking.

I'm certainly not an expert, but this is how I do it:

from logging import INFO, getLogger, Formatter, handlers

logger = getLogger()
logger.setLevel(INFO)
_handler = handlers.TimedRotatingFileHandler(
virtualenv / 'var/log/openerp/continuous_sync_records.log',
when='midnight',
backupCount=30,
)
_formatter = Formatter('%(asctime)s %(funcName)-25s %(message)s')
_handler.setFormatter(_formatter)
logger.addHandler(_handler)
del _handler, _formatter

and then in my code:

logger.info('failure converting %r to %r', target_bmp_file, target_png_file)

--
~Ethan~

1
server_pubkey.txt

rocksolid light 0.9.81
clearnet tor