From: Lorenzo Beretta <lory.fulgi@infinito.it>
To: supervision@list.skarnet.org
Subject: Re: [magic sv logging]
Date: Fri, 21 Sep 2012 17:29:51 +0200 [thread overview]
Message-ID: <k3i15f$ie4$1@ger.gmane.org> (raw)
In-Reply-To: <CAK2oqqK_01vac0fV=2XQD7=KFUGvPsaWmTQCSzxVjieSq6qCTQ@mail.gmail.com>
On 21/09/2012 04:25, Mike Buland wrote:
> I took a different approach and monitored the log output of svlogd, since I
> wanted the logs anyway. This is some code that well help you with that,
> anyway:
>
> import os
> import time
> import stat
>
> fIn = open("current", "r")
> sid = os.stat("current")[stat.ST_INO]
>
> while True:
> try:
> sidNew = os.stat("current")[stat.ST_INO]
> if sidNew != sid:
> fIn.close()
> fIn = open("current", "r")
> sid = sidNew
> except:
> time.sleep( 1 )
> continue
>
> while True:
> l = fIn.readline()
> if l is None or l == '':
> break
> # do something interesting with your line here
> time.sleep( 1 )
>
> This will read everything from current, and when current moves, it will
> read what's left, open the new current, and read all of it. I use it to
> monitor apache log output, and it hasn't failed me yet.
>
> --Mike
Unless I missed something, it looks as if you're reimplementing the '-F'
flag in tail :)
next prev parent reply other threads:[~2012-09-21 15:29 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-09-20 23:35 Sergiusz Pawlowicz
2012-09-21 2:25 ` Mike Buland
2012-09-21 15:29 ` Lorenzo Beretta [this message]
2012-09-21 15:32 ` Mike Buland
2012-09-21 15:35 ` Jason Dusek
2012-09-21 15:38 ` Mike Buland
2012-09-22 4:18 ` Laurent Bercot
2012-09-22 5:58 ` Jason Dusek
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to='k3i15f$ie4$1@ger.gmane.org' \
--to=lory.fulgi@infinito.it \
--cc=supervision@list.skarnet.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).