[mythtv] [Patch] Logging to database PLUS automatic mythfilldatabase

Matt White whitem at arts.usask.ca
Fri Feb 27 12:35:12 EST 2004


Joseph A. Caputo wrote:

> Glad I could help.  Would you be able to add a size limit to the log 
> table as well?  Either per-module or overall.  After (or before) 
> inserting a log message (assuming it's not a repeat), you can do a:
> 
> SELECT COUNT(*) from mythlog WHERE module = <module name>
> 
> to get the current number of entries for a module; if it's greater than 
> some maximum, enter a loop where you delete the oldest entry for that 
> module until it's below the max number of entries.  Actually, there's 
> probably a clever way to delete the <n> oldest entries, but my SQL 
> isn't good enough...
> 
> In any event, the simple case is that you should only ever have 1 entry 
> to delete, unless you've lowered the max number (which would be 
> configurable) since the last time the housekeeping thread ran.

I was trying to make the log call fairly quick, since it's being run
in-line during regular operation and not in its own thread.  I don't
know how much of an issue that is - like you say, it should be a pretty
simple check.  I'll do some experimenting...

I think it should be fairly simple to just do

SELECT logid FROM mythlog WHERE module=<modulename> ORDER BY ldate ASC;

and then just deleting the first x events returned to get down under the
limit...

> One last thing... (and I haven't looked at the UI for the logs, so maybe 
> you already filter this out of the UI...)  Does it really make sense to 
> keep logs in the database after they've been acknowledged?  At the very 
> least they should be filtered out of the UI view, but I don't know that 
> there's really any point to keeping them in the DB once they've been 
> acknowledged.  Just something to chew on.

The UI only shows non-acknowledged events.  I didn't do deletes from the
mythlog module for a couple of reasons:  First, I figured that the
cleanup stuff should be done in the main code, since a user doesn't
necessarily need MythLog installed.  Second is that in some cases, you
may want to have the Log view there for convenience, but have the
logs mailed out as well periodically.  That's what I'm doing for my
parents - I have it set so that the UI shows them important errors, and
dad can look at it and deal with most of them, but it also emails me all
of the events every couple of days so I can see if anything's up.
That's kind of a special case, I know.

-- 
Matt White                          whitem at arts.usask.ca
Arts and Science Computer Labs      University of Saskatchewan

I used to think they were after me...
But they're just after my recipe.
	- Joe Diffie..."Good Brown Gravy"



More information about the mythtv-dev mailing list