Adding a package special log file to apport

Brian Murray brian at ubuntu.com
Fri May 18 19:31:05 UTC 2012


On Fri, May 18, 2012 at 03:09:52PM -0400, Daniel Manrique wrote:
> On 12-05-18 01:39 PM, Lars Düsing wrote:
> > Hi all,
> > Is there any way to add a log file to apport on crash of a specific package?
> > I need /var/log/aiccu.log on crash of aiccu...
> > 
> > Thanks,
> > Lars
> > 
> 
> 
> Look here for information on how to add package hooks to do stuff like this:
> 
> https://wiki.ubuntu.com/Apport/DeveloperHowTo#Package_Hooks
> 
> In brief (and don't believe me too much, I've never done it, I'm just reading
> the docs and comparing against what a package I know does this has):
> 
> - Add a Python script/file/hook to your package (say, aiccu.py) with something
> like this:
> 
> from apport.hookutils import *
> 
> def add_info(report, ui=None):
>     attach_file_if_exists(report, '/var/log/aiccu.log', key='aiccuLog')
>     report['SecretMessage'] = 'my hook was here'
> 
> 
> - Make sure your package installs it in /usr/share/apport/package-hooks/aiccu.py.

Well, if the aiccu package generates multiple binary packages then you'd
want to name it source_aiccu.py so the package hook would be run for
every binary package.

There are also lots of examples on most ubuntu systems in
/usr/share/apport/package-hooks.  Additionally, there are some
convenience functions for adding information in hookutils.py like
attach_file_if_exists which was mentioned in the code snippet.

Oh and you initially mentioned you only want this for crashes, so keepng
in mind that package hooks are also run when someone uses 'ubuntu-bug
aiccu', you'd probably want:

        if report['ProblemType'] == 'Crash':
            attach_file_if_exists(...)

Also if you need the changes to package sponsored or SRU'ed (you'd
probably want it in Precise), I am happy to help.

--
Brian Murray



More information about the Ubuntu-bugsquad mailing list