[Python-Dev] logging and rotation
Dear mailing list, I'm using the logging module and write my log messages via the FileHandler. I just realized that using an external log rotation mechanism does not work. That is, new messages are not added to the file after rotation. In my opinion external log rotate mechanisms should work with the standard file handler. websearch pointed me to TimedRotatingFileHandler . But this only seems like a workaround. For instance I would like to get my log file mailed once a week. But it seems difficult to sync the cron job doing this and the logging-rotation mechanism. I think TimedRotatingFileHandler is important, e.g. for windows users. But for *nux users this seems to be unnecessary. Just want to gather some opinions before filing a bug. Regards, Matthias ___ Python-Dev mailing list [email protected] http://mail.python.org/mailman/listinfo/python-dev Unsubscribe: http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com
Re: [Python-Dev] logging and rotation
On Sun, Nov 25, 2012 at 01:14:11PM +0100, Matthias Bernt wrote: > I'm using the logging module and write my log messages via the FileHandler. > I just realized that using an external log rotation mechanism does not > work. That is, new messages are not added to the file after > rotation. An external log rotation mechanism ought to send a signal to the application and the application ought to close and reopen logs. That is, this is an application-level problem, not logging module-level. Oleg. -- Oleg Broytmanhttp://phdru.name/[email protected] Programmers don't die, they just GOSUB without RETURN. ___ Python-Dev mailing list [email protected] http://mail.python.org/mailman/listinfo/python-dev Unsubscribe: http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com
Re: [Python-Dev] logging and rotation
On 2012-11-25, at 18:02 , Oleg Broytman wrote: > On Sun, Nov 25, 2012 at 01:14:11PM +0100, Matthias Bernt > wrote: >> I'm using the logging module and write my log messages via the FileHandler. >> I just realized that using an external log rotation mechanism does not >> work. That is, new messages are not added to the file after >> rotation. > > An external log rotation mechanism ought to send a signal to the > application and the application ought to close and reopen logs. That is, > this is an application-level problem, not logging module-level. I don't know that FileHandler officially supports reopening its underlying file. On the other hand, WatchedFileHandler[0] does exactly that and is specifically advertised for use with external log rotators: > WatchedFileHandler […] watches the file it is logging to. If the file > changes, it is closed and reopened using the file name. > A file change can happen because of usage of programs such as newsyslog > and logrotate which perform log file rotation. […] If the file has changed, > the old file stream is closed, and the file opened to get a new stream. [0] http://docs.python.org/2/library/logging.handlers.html#watchedfilehandler ___ Python-Dev mailing list [email protected] http://mail.python.org/mailman/listinfo/python-dev Unsubscribe: http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com
Re: [Python-Dev] logging and rotation
On Sun, Nov 25, 2012 at 9:02 AM, Oleg Broytman wrote: > On Sun, Nov 25, 2012 at 01:14:11PM +0100, Matthias Bernt > wrote: >> I'm using the logging module and write my log messages via the FileHandler. >> I just realized that using an external log rotation mechanism does not >> work. That is, new messages are not added to the file after >> rotation. > >An external log rotation mechanism ought to send a signal to the > application and the application ought to close and reopen logs. That is, > this is an application-level problem, not logging module-level. I'm not so sure. Logging ought to "just work" without the application having to do much about it the details. Log rotation is definitely a useful feature; I've run into this very issue before and never found a satisfactory solution. Surely it should be possible for the file handler to occasionally stat() its output file by name and compare that to fstat() for the file descriptor and if they differ, reopen? -- --Guido van Rossum (python.org/~guido) ___ Python-Dev mailing list [email protected] http://mail.python.org/mailman/listinfo/python-dev Unsubscribe: http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com
[Python-Dev] type vs. class terminology
I would like to know when we should use "class" in the Python 3 documentation, and when we should use "type." Are these terms synonymous in Python 3, and do we have a preference for which to use and when? I'm sure this has been discussed before. But if this terminology issue has already been resolved, the resolution doesn't seem to be reflected in the docs. For example, the glossary entries for type and class don't reference each other. Thoughts? --Chris ___ Python-Dev mailing list [email protected] http://mail.python.org/mailman/listinfo/python-dev Unsubscribe: http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com
Re: [Python-Dev] type vs. class terminology
On Mon, Nov 26, 2012 at 3:01 PM, Chris Jerdonek wrote: > I would like to know when we should use "class" in the Python 3 > documentation, and when we should use "type." Are these terms > synonymous in Python 3, and do we have a preference for which to use > and when? > > I'm sure this has been discussed before. But if this terminology > issue has already been resolved, the resolution doesn't seem to be > reflected in the docs. For example, the glossary entries for type and > class don't reference each other. > The historical distinction between "builtin types" and "user-defined classes" predates new-style classes (which unified the type system) and Python 3 (which eliminated the "instance" type that was provided to preserve the legacy user-defined class semantics in Python 2). The glossary unfortunately still reflects this distinction, which no longer exists in Python 3. A slightly more useful distinction would be if type was used consistently to refer to type(x), while class was used to refer to x.__class__, since they can and do differ in the case of proxy types (like weakref.proxy). However, it's probably too late for that kind of fine distinction - in reality, the two terms are now used pretty much interchangeably. Cheers, Nick. -- Nick Coghlan | [email protected] | Brisbane, Australia ___ Python-Dev mailing list [email protected] http://mail.python.org/mailman/listinfo/python-dev Unsubscribe: http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com
Re: [Python-Dev] type vs. class terminology
On 2012-11-26, at 07:54 , Nick Coghlan wrote: > On Mon, Nov 26, 2012 at 3:01 PM, Chris Jerdonek > wrote: > >> I would like to know when we should use "class" in the Python 3 >> documentation, and when we should use "type." Are these terms >> synonymous in Python 3, and do we have a preference for which to use >> and when? >> >> I'm sure this has been discussed before. But if this terminology >> issue has already been resolved, the resolution doesn't seem to be >> reflected in the docs. For example, the glossary entries for type and >> class don't reference each other. >> > > The historical distinction between "builtin types" and "user-defined > classes" predates new-style classes (which unified the type system) and > Python 3 (which eliminated the "instance" type that was provided to > preserve the legacy user-defined class semantics in Python 2). The glossary > unfortunately still reflects this distinction, which no longer exists in > Python 3. > > A slightly more useful distinction would be if type was used consistently > to refer to type(x), while class was used to refer to x.__class__, since > they can and do differ in the case of proxy types (like weakref.proxy). > However, it's probably too late for that kind of fine distinction - in > reality, the two terms are now used pretty much interchangeably. There's an other possible usage which is between `type` subclasses and `type` instances (`type` essentially becomes a synonym for `metaclass`), I've seen that kind of usage at least once in the docs: http://docs.python.org/2/c-api/object.html#PyObject_IsInstance > If cls is a type object rather than a class object, PyObject_IsInstance() > returns 1 if inst is of type cls. ___ Python-Dev mailing list [email protected] http://mail.python.org/mailman/listinfo/python-dev Unsubscribe: http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com
Re: [Python-Dev] type vs. class terminology
On 11/26/2012 06:01 AM, Chris Jerdonek wrote: I would like to know when we should use "class" in the Python 3 documentation, and when we should use "type." Are these terms synonymous in Python 3, and do we have a preference for which to use and when? Some people like to use "class" for the subset of types created by Python's "class" statement or its moral equivalent (explicit invocation of the metaclass). It makes sense that "class" is used to create classes. The word "type" then refers to both classes and built-in and extension types, such as "list" or "array.array". ___ Python-Dev mailing list [email protected] http://mail.python.org/mailman/listinfo/python-dev Unsubscribe: http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com
