[Twisted-Python] Dumb Logger API question

Kevin Mcintyre kebin70 at gmail.com
Tue Nov 10 22:09:22 MST 2015


yes, I stared at that section for a bit.  Not to get off topic, but the
readability of the api docs from back when is slightly better in my
opinion.  So the topic being I'm an idiot - thanks for both
examples...that's a perfect example.

I got confused by "from myobservers import PrintingObserver" cause I'm
wondering if myobservers is a core package.

On Tue, Nov 10, 2015 at 6:05 PM, Glyph Lefkowitz <glyph at twistedmatrix.com>
wrote:

>
> On Nov 9, 2015, at 2:29 PM, Kevin Mcintyre <kebin70 at gmail.com> wrote:
>
> http://twistedmatrix.com/documents/current/core/howto/logger.html
>
> I'm looking at the new-ish logger api and wonder how to log to console as
> a first step to transitioning.
>
> Any pointers?  Thanks.
>
>
> Do you mean "emit structured log text to stdout"?  In that case, that is
> covered in the document you link to; these two sections:
>
>
> http://twistedmatrix.com/documents/current/core/howto/logger.html#avoid-mutable-event-keys
>
> http://twistedmatrix.com/documents/current/core/howto/logger.html#starting-the-global-log-publisher
>
> create a jsonFileLogObserver and start logging to it:
>
> import sys
> from twisted.logger import jsonFileLogObserver, globalLogBeginner, Logger
> globalLogBeginner.beginLoggingTo([jsonFileLogObserver(sys.stdout)])
> log = Logger()
> log.info("Information.")
>
>
> If you want unstructured log output for human reading (not a good choice
> for an automated system, but perhaps useful for debugging), you can instead
> go with textFileLogObserver, in almost exactly the same way:
>
> import sys
> from twisted.logger import textFileLogObserver, globalLogBeginner, Logger
> globalLogBeginner.beginLoggingTo([textFileLogObserver(sys.stdout)])
> log = Logger()
> log.info("Information.")
>
>
> Is this what you were looking for?
>
> -glyph
>
> _______________________________________________
> Twisted-Python mailing list
> Twisted-Python at twistedmatrix.com
> http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: </pipermail/twisted-python/attachments/20151110/4ba63694/attachment-0002.html>


More information about the Twisted-Python mailing list