Hi Igmar, If bundle Y wants to know its immediate caller then it can call Thread.currentThread.getStackTrace(). The problem is, this will not tell you from which bundle you were called -- the only way to get that kind of information is to register a ServiceFactory.
What is the purpose of bundle Y? It just seems to be getting in the way. Why not call the LogService directly from bundle X? Regards, Neil On Tue, Nov 2, 2010 at 2:17 AM, Igmar Palsenberg <[email protected]> wrote: > Hi, > > We're OSGi-fying a framework we are building. Logging itself isn't a problem, > since OSGi already provides that infrastructure. What I'm not to happy about > is that I keep loosing part of the call chain : > > Assume that we have bundle X that does some work, and makes a call to > something in bundle Y. In Y something goes wrong, and that event needs to be > logged. What I want is that the logging indicates that the caller is actually > class Foo in bundle X. We can use a service factory, but that will indicate > that bundle Y made that call to the logging service (for now, we assume that > it is a registered running service). So : > > X class Foo > | > | > Y class Bar > | > | > Service Logger > > I want a logging lines as : X::Foo() method Save() failed : <something else, > a stacktrace, whatever). In this case, I want the logging line to indicate > that the caller is actually X::Foo::Save(). > > To clarify things : Bundle Y is generic code, so we want those messages to be > redirected to the logfile for bundle X, since that is the caller. OSGi > provides a log service per bundle, so all logging of bundle Y is redirected > to the log service of that bundle (and that usually means all those messages > end up in the some destination, which is in this case bad for code that is > used by a couple of hundred different bundles). > > Can someone point me in the right direction on how to implement this ? > > > Regards, > > > Igmar > _______________________________________________ > OSGi Developer Mail List > [email protected] > https://mail.osgi.org/mailman/listinfo/osgi-dev > _______________________________________________ OSGi Developer Mail List [email protected] https://mail.osgi.org/mailman/listinfo/osgi-dev
