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


Groups > comp.lang.python > #95496

Re: Logging to a file from a C-extension

From Stefan Behnel <stefan_ml@behnel.de>
Subject Re: Logging to a file from a C-extension
Date 2015-08-19 21:51 +0200
References <SNT151-W75B708F094CE1F2C687FFFB1780@phx.gbl>
Newsgroups comp.lang.python
Message-ID <mailman.16.1440013897.28100.python-list@python.org> (permalink)

Show all headers | View raw


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

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


Thread

Re: Logging to a file from a C-extension Stefan Behnel <stefan_ml@behnel.de> - 2015-08-19 21:51 +0200

csiph-web