Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [platform-core-dev] logging conventions


Well, the general rule is to propagate exceptions back to the caller of the core API as much as possible.  Logging is mainly used in contexts where rethrowing the exception is not possible because it lies beneath API that does not declare a throws clause (such as IResource#isSynchronized). It may also be used where the failure is a minor side-effect and failing the entire operation doesn't make sense. Also, extra logging may be added for the purpose of isolating a bug.

There is no substantial difference between the two Policy#log convenience methods you describe - except of course that one takes an exception and one takes an IStatus... it depends which object you happen to have on hand.  Wrapping an exception in an IStatus allows additional an additional error message to be included in the log that gives more information about the context of the failure.  On the other hand, unwrapping a status from an exception (using CoreException#getStatus()) can sometimes cause the stack trace of the failure to be lost.  So, I guess the guideline is to make sure you log something that contains a stack trace, and to add additional context information (such as resource path or error message) if logging the underlying exception doesn't provide enough information.




"Arjun Singh" <aasingh@xxxxxxxxx>
Sent by: platform-core-dev-bounces@xxxxxxxxxxx

01/11/2006 12:34 PM

Please respond to
"Eclipse Platform Core component developers list." <platform-core-dev@xxxxxxxxxxx>

To
platform-core-dev@xxxxxxxxxxx
cc
Subject
[platform-core-dev] logging conventions





I have a question about logging in the Eclipse core projects.  Is
there a general policy or convention for logging (e.g. what to log and
when to log it)?

I also have a question about a more specific situation.  In exception
handlers, there is sometimes a call to Policy.log(Throwable).  However
sometimes there is a call to Policy.log(IStatus).  For example, in the
CoreException handler in FileSystemResourceManager.isSynchronized() in
the org.eclipse.core.internal.resources project, there is a call to
the former, but in many other handlers of CoreExceptions in the
project, the latter is used.  Is there a general policy or convention
about which one to use?

Thanks,
Arjun
_______________________________________________
platform-core-dev mailing list
platform-core-dev@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/platform-core-dev


Back to the top