[systemd-devel] Journald logging handler for Python 3 and AsyncIO integration

Ludovic Gasc gmludo at gmail.com
Sat May 2 07:31:44 PDT 2015


2015-05-02 16:18 GMT+02:00 Zbigniew Jędrzejewski-Szmek <zbyszek at in.waw.pl>:

> On Sat, May 02, 2015 at 03:34:52PM +0200, Ludovic Gasc wrote:
> > Ok, my bad, I didn't see JournalHandler class to use with Python logging:
> >
> http://www.freedesktop.org/software/systemd/python-systemd/journal.html#journalhandler-class
> >
> > Nevertheless, my question about communication between Python and journald
> > remains.
> Can you rephrase the question? I don't quite understand what functionality
> you're missing from
>
> http://www.freedesktop.org/software/systemd/python-systemd/journal.html#systemd.journal.send
> .
>
>
In AsyncIO, when you interact with the outside world, you need to use
"yield from", for example:
https://docs.python.org/3/library/asyncio-stream.html#tcp-echo-client-using-streams

"yield from" means to the Python interpreter to "pause" the coroutine to
work on another coroutine until data arrive.
To be efficient, I/O should handled by AsyncIO, even if some workarounds
are possible if the raw socket isn't accessible.

If this pattern is useful for HTTP requests, for logging where you
shouldn't wait a return, it isn't very critical, especially if you use
syslog protocol with UNIX socket.

Nevertheless, to be sure, I wish to understand how the communication works
between my process and journald daemon.


> Zbyszek
>
> >
> > --
> > Ludovic Gasc (GMLudo)
> > http://www.gmludo.eu/
> >
> > 2015-05-02 15:12 GMT+02:00 Ludovic Gasc <gmludo at gmail.com>:
> >
> > > Hi,
> > >
> > > With the new release of Debian Jessie and systemd+journald integration,
> > > I'm looking for how to modernize our Python 3 toolbox to build daemons.
> > >
> > > For now on Debian Wheezy, we use a SysLogHandler with UNIX socket:
> > >
> https://docs.python.org/3.4/library/logging.handlers.html#sysloghandler
> > > + a custom rsyslog+logrotate configuration to split and manage log
> files.
> > >
> > > From sysvinit to systemd migration to start our daemons, it should be
> > > easy, I've found this documentation:
> > > http://gunicorn-docs.readthedocs.org/en/latest/deploy.html#systemd
> > >
> > > But for journald, even if I can use syslog UNIX socket provided by
> > > journald, I want to benefit the features of journald, especially
> structured
> > > logs.
> > >
> > > I've seen the Python binding for journald:
> > >
> http://www.freedesktop.org/software/systemd/python-systemd/journal.html
> > > Nevertheless, I've two questions:
> > >
> > >    1. I've seen no python logging handler for journald. Is it a desired
> > >    situation or it's because no time to implement that ? Could you be
> > >    interested in by an handler with journald ?
> > >    2. We use heavily AsyncIO module to have async pattern in Python,
> > >    especially for I/O: https://docs.python.org/3/library/asyncio.html
> > >    In the source code of python-systemd, I've seen that you use a C
> glue
> > >    to interact with journald, but I don't understand what's the
> communication
> > >    between my Python daemon process and journald: unix sockets ? Other
> > >    mechanism ? Depends on the mechanism, it should be have an impact
> for us.
> > >
> > > Thanks for your answers.
> > >
> > > Have a nice week-end.
> > > --
> > > Ludovic Gasc (GMLudo)
> > > http://www.gmludo.eu/
> > >
>
> > _______________________________________________
> > systemd-devel mailing list
> > systemd-devel at lists.freedesktop.org
> > http://lists.freedesktop.org/mailman/listinfo/systemd-devel
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freedesktop.org/archives/systemd-devel/attachments/20150502/e7369eb0/attachment.html>


More information about the systemd-devel mailing list