Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #111880

Re: Caller's module name, function/method name and line number for output to logging

Path csiph.com!fu-berlin.de!uni-berlin.de!not-for-mail
From Peter Otten <__peter__@web.de>
Newsgroups comp.lang.python
Subject Re: Caller's module name, function/method name and line number for output to logging
Date Tue, 26 Jul 2016 08:47:44 +0200
Organization None
Lines 18
Message-ID <mailman.123.1469515692.22221.python-list@python.org> (permalink)
References <1469474181.734306.676367265.29267D36@webmail.messagingengine.com> <nn5v29$tri$1@ger.gmane.org> <1469486429.2217869.676546129.5F3AEEE4@webmail.messagingengine.com> <nn712v$66o$1@ger.gmane.org>
Mime-Version 1.0
Content-Type text/plain; charset="ISO-8859-1"
Content-Transfer-Encoding 7Bit
X-Trace news.uni-berlin.de Pi1NawQI3vZPJsbePC6nqApaPRkacKn/po0nakwJLKug==
Return-Path <python-python-list@m.gmane.org>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.001
X-Spam-Evidence '*H*': 1.00; '*S*': 0.00; 'url:pipermail': 0.05; 'subject:number': 0.07; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'subject:method': 0.09; 'subject:module': 0.09; 'stack': 0.13; 'malcolm': 0.16; 'received:80.91.229.3': 0.16; 'received:dip0.t-ipconnect.de': 0.16; 'received:io': 0.16; 'received:plane.gmane.org': 0.16; 'received:psf.io': 0.16; 'received:t-ipconnect.de': 0.16; 'wrote:': 0.16; 'hack': 0.18; '>>>': 0.20; 'function,': 0.22; 'module': 0.25; 'header:User- Agent:1': 0.26; 'header:X-Complaints-To:1': 0.26; 'inspect': 0.29; 'subject:/': 0.30; 'up.': 0.32; 'url:python': 0.33; 'there': 0.36; 'url:org': 0.36; 'to:addr:python-list': 0.36; 'subject:: ': 0.37; 'received:org': 0.37; 'url:mail': 0.40; 'to:addr:python.org': 0.40; 'received:de': 0.40; 'avoid': 0.61; 'information': 0.63; 'levels': 0.70; 'perfect!': 0.84; 'technique': 0.93
X-Injected-Via-Gmane http://gmane.org/
X-Gmane-NNTP-Posting-Host p57bd8c98.dip0.t-ipconnect.de
User-Agent KNode/4.13.3
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.22
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 <http://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 <nn712v$66o$1@ger.gmane.org>
X-Mailman-Original-References <1469474181.734306.676367265.29267D36@webmail.messagingengine.com> <nn5v29$tri$1@ger.gmane.org> <1469486429.2217869.676546129.5F3AEEE4@webmail.messagingengine.com>
Xref csiph.com comp.lang.python:111880

Show key headers only | View raw


Malcolm Greene wrote:

> Hi Terry,
> 
>>> Is there a technique for accessing a function's *CALLER* module name,
>>> function/method name and line number so that this information can be
> 
>> Look in the inspect module for the inspect stack function.  Note that
>> when you call the function, it needs to look 2 levels up.
> 
> Perfect! That's exactly what I was looking for.

Fine! Then you can avoid the evil hack I came up with many moons ago:

https://mail.python.org/pipermail/python-list/2010-March/570941.html

;)

Back to comp.lang.python | Previous | Next | Find similar | Unroll thread


Thread

Re: Caller's module name, function/method name and line number for output to logging Peter Otten <__peter__@web.de> - 2016-07-26 08:47 +0200

csiph-web