[Libreoffice] Assertions and Logging

Caolán McNamara caolanm at redhat.com
Mon Nov 21 07:42:04 PST 2011


On Mon, 2011-11-21 at 14:30 +0100, Stephan Bergmann wrote:
> On 11/21/2011 01:30 PM, Caolán McNamara wrote:
> > Practical question though, is on windows where does the output go ?
> 
> SAL_INFO/WARN just go to stderr for now.  What should work to see them 
> even for a gui soffice.exe is to add something like 2>log.txt to the 
> command line.  

oh, does that work ? I was labouring under the misunderstanding that we
closed those streams under windows, or something of that nature. I'm a
complete windows weenie.

> >
> > assert(pFoo);
> > if (!pFoo)
> >      throw catchAbleFoo("wtf");
> >
> > i.e. do we have a philosophical problem with gracefully/semi-gracefully
> > handing should-be impossible cases ?
> 
> I think that's a perversion, and should be avoided.  It the author could 
> not convince himself that !pFoo is not impossible (modulo bugs), then he 
> should use OSL_WARN instead.  If however he *is* convinced that !pFoo is 
> impossible absent any bugs, but argues that if there *are* bugs, the 
> added if statement adds some sort of safety,

I have no strong feelings either way, but might as well agree now while
we can. So the plan is that asserts are for 100% can never happen
things. So that would suggest that anything which might fail for
external reasons is not a candidate for assert.

oslModule hModule= osl_loadModule( foo );
assert(hModule)
if (!hModule)
    throw bar;

is wrong, because foo might not exist if some member of the lunatic
fringe deleted some .sos out of his install. Or more fairly, his distro
tried to split up packages into subpackages and mis-categorized one of
them.

In which case, we should use SAL_WARN to indicate its an unlikely and
suspicious event. So do we then consider SAL_WARNs as failures from the
perspective of e.g. the smoketest where we can argue reasonably that
we're in a controlled environment and nothing unusual should occur ?

C.



More information about the LibreOffice mailing list