[vbox-dev] Logging in Custom COM Implementations
klaus.espenlaub at oracle.com
Mon Oct 15 04:24:52 PDT 2012
On 11.10.2012 06:25, Adam Pridgen wrote:
> First thank you to everyone who has been helpful so far. Right now,
> I am trying to figure out how to set-up logging for my custom interface.
Just don't forget that you need to change the UUID of every interface
you're touching, and that such UUID changes have the consequence that
your VirtualBox build is incompatible with 3rd party API clients which
are created for a particular major version (which is why we have the "do
not change the API" policy for maintenance versions).
This means that it's not possible to have 3rd party API extensions which
aren't at least partially included in the official version.
> I am still shaky about some aspects of the logging frame work
> after reading the help page, postings on the mailing list, and some
> of the source code in iprt/logging.h, and I have two questions:
> 1) How do I specify or enable logging for a function in the implementation
> of my custom COM interface?
If your code includes include/Logging.h early (before anything else
drags in iprt/log.h) then all logging will go to the log group "main".
Of course this needs debug logging to be enabled, which is not the case
for release builds. If you create a debug or dbgopt build then logging
is enabled (and assertions are, too).
> 2) What is a VBOX_LOG_FLAGS setting/configuration that I can use to capture
> *all* logging messages to "stderr"? Using "VBOX_LOG=all" alone does not
> capture any of the messages in my COM interface or the added logging
> messages I added to parts of VB.
Where does your code live? In VBoxSVC or in the API client? If it's the
former then doing stderr logging is only sensible when you always run it
manually (which also helps with getting the right environment variables
> Below is an example to help conceptualize what I am trying to do in question 1
> with a number of details omitted. First, I have created an
> implementation for a
> COM interface, and DoFoo is a function that will be called via the VBoxManage
> For the sake of the example, the implementation class exists in
> src/VBox/Main/src-client/BarImpl.cpp, and the implementation makes calls
> to the logging framework (similar to src/VBox/Main/src-client/ConsoleImp,
> Console::PowerDown 2029:2030). I have also used LogAlways for testing
OK, I assume that this answers my question about client/server side above.
> To enable logging and capture messages from this particular class, I set
> my environment variables to the following:
You apparently missed https://www.virtualbox.org/wiki/VBoxLogging
completely. From the above you seem to think that there is some
automatic C++ class relationship for the logging which simply doesn't
exist. There are only logging groups which are explicitly named. The
whole syntax is wrong...
> When I attempt to use the above configuration to capture logging along with the
> logged messages, I get the following error:
> !!Assertion Failed!!
> Location : /some/path/vbox/src/VBox/Runtime/common/log/log.cpp(1711)
> int RTLogFlags(PRTLOGGER, const char*)
> Invalid flags! unknown instruction bar.e.f
> Trace/breakpoint trap (core dumped)
Shouldn't be a surprise any more once you read the wiki page.
> Sorry for the long email, and please let me know if more details are needed
> to help answer this question. Thanks,
> -- Adam
More information about the vbox-dev