Path: csiph.com!news.mixmin.net!feeder1.xsusenet.com!newsfeed.xs4all.nl!newsfeed7.news.xs4all.nl!nzpost1.xs4all.net!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.000 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'subject:file': 0.07; 'logger': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'python': 0.10; 'output': 0.13; 'suggest': 0.15; 'instead.': 0.15; 'code),': 0.16; 'file?': 0.16; 'formatting.': 0.16; 'from:addr:behnel.de': 0.16; 'from:addr:stefan_ml': 0.16; 'from:name:stefan behnel': 0.16; 'received:80.91.229.3': 0.16; 'received:plane.gmane.org': 0.16; 'subject:Logging': 0.16; 'obviously': 0.16; 'stefan': 0.18; 'extension': 0.20; 'filtering': 0.22; '(where': 0.23; 'header:In- Reply-To:1': 0.24; 'header:User-Agent:1': 0.26; 'header:X -Complaints-To:1': 0.26; 'logging': 0.27; 'idea': 0.28; "i'd": 0.31; 'implement': 0.32; 'instead,': 0.33; 'file': 0.34; 'level': 0.35; 'but': 0.36; 'to:addr:python-list': 0.36; 'subject:: ': 0.37; 'received:org': 0.37; 'log': 0.38; 'subject:from': 0.39; 'subject:-': 0.39; 'to:addr:python.org': 0.40; 'received:de': 0.40 X-Injected-Via-Gmane: http://gmane.org/ To: python-list@python.org From: Stefan Behnel Subject: Re: Logging to a file from a C-extension Date: Wed, 19 Aug 2015 21:51:24 +0200 References: Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-Gmane-NNTP-Posting-Host: dslb-088-067-009-142.088.067.pools.vodafone-ip.de User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.7.0 In-Reply-To: X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.20+ Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 14 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1440013897 news.xs4all.nl 23777 [2001:888:2000:d::a6]:44979 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:95496 Al Pfalzgraf schrieb am 18.08.2015 um 15:07: > If a logging file is opened at the level of a Python application, how > would the log file name be communicated to a C-extension so that logging > from the extension would be sent to the same log file? Writing to the file directly (as was suggested) may not be a good idea as it would bypass the log filtering and formatting. Instead, I'd suggest sending output to a normal Python Logger object instead. This is obviously trivial in Cython (where you can just implement it in Python code), but you can do the same in C with just the usual C-API overhead. Stefan