[vbox-dev] Logging in Custom COM Implementations
Adam Pridgen
adam.pridgen at thecoverofnight.com
Wed Oct 10 21:25:33 PDT 2012
Hello,
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.
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?
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.
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
Frontend.
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
purposes.
Snippet from src/VBox/Main/src-client/BarImpl.cpp
// Bar implements the IBar interface, which is
// defined in the VirtualBox.xidl
STDMETHODIMP Bar::DoFoo()
{
LogFlowThisFuncEnter();
LogFlowThisFunc(("DoFoo is barring.\n"));
LogAlways(("Bar addr for this: 0x%08x", this));
AutoCaller autoCaller(this);
HRESULT hrc = autoCaller.rc();
Console::SafeVMPtrQuiet pVM (mParent);
if (!pVM.isOk())
return setError(VBOX_E_INVALID_VM_STATE, "Machine is not running");
LogFlowThisFuncLeave();
return hrc;
}
To enable logging and capture messages from this particular class, I set
my environment variables to the following:
VBOX_LOG_FLAGS=bar.e.f
VBOX_LOG=all
VBOX_LOG_DEST=stderr
When I attempt to use the above configuration to capture logging along with the
logged messages, I get the following error:
!!Assertion Failed!!
Expression: <none>
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)
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
mailing list