Debugview not picking up _Trace call from DLL

I have a wrapper around a call to gSite.CallFunction() for the _Trace command in AmiBroker. When I pass it a static string like so,

ab_Trace("This is a static string");

Everything goes fine. DebugView picks it up just like when _Trace is called from AmiBroker. However, when I call it with a string created using run-time values, as below,

float NumericValue = 15;
ab_Trace("This string is created at runTime: " + to_string(NumericValue));

everything seems to work but DebugView does not pick up the message. When I say "everything seems to work", what I mean is that it throws no errors, and when I do a VS debug session, the string shows up in the VS output window, and nothing seems amiss when I set a breakpoint and walk through the function looking at the variable values. The same behavior/problem occurs if I instead pipe to clog or send the string directly through OutputDebugString() instead of Amibroker.

I am running DebugView as administrator and it is monitoring all streams, as you can see from this screenshot:

image

I have also tried sending the string using .data() and .c_string() with no luck. I have tried concatenating "\n\0" to the end of the string, and no luck. I've been googling this for a few days and have found nothing that helps/explains this behavior.

What is the difference between static and run-time created strings which keeps DebugView from receiving the latter? Can I do anything about it?

Code for the wrappers is below,

void ab_Trace(const char *message) {
	AmiVar _args[1];
	string msg(message);
	size_t msgSize = msg.length();

	_args[0].type = VAR_STRING;
	_args[0].string = (char*)gSite.Alloc(static_cast<unsigned int>(sizeof(char) * (msgSize + static_cast<size_t>(1))));
	strcpy_s(_args[0].string, msgSize + static_cast<size_t>(1), message);

	gSite.CallFunction("_TRACE", 1, _args);
} // End ab_Trace

void ab_Trace(string & message) {
	AmiVar _args[1];
	size_t msgSize = message.length();

	_args[0].type = VAR_STRING;
	_args[0].string = (char*)gSite.Alloc(static_cast<unsigned int>(sizeof(char) * (msgSize + static_cast<size_t>(1))));
	strcpy_s(_args[0].string, msgSize + static_cast<size_t>(1), message.data());

	gSite.CallFunction("_TRACE", 1, _args);
} // End ab_Trace

As I said many times, don't write plugins at all:

_TRACE just calls OutputDebugString Windows API so if you don't get output from OutputDebugString it means that something else on your system is eating messages. If you are using Visual Studio for debugging, it is eating ODS calls and outputs them in its own window (so they are not going to DebugView).

Yes, it's obviously eating the messages. That's why I'm posting. When I was googling, I found info about debugging redirecting ODS to the output window in VS. A couple of things about this,

  1. Why isn't it also eating calls with static strings? This only happens if the string contains runtime information. Otherwise, it works just fine. Does anybody know of a setting to make strings with runtime information behave like static strings do when sent to _Trace or ODS? The VS output window is actually a less friendly message environment than DebugView.

  2. I have tried running AB without VS in debugging mode, and the same issue occurs. I believe I was still using the debug version of the compiler output, just not actually attaching VS to AB in debug mode. Perhaps the issue won't occur if I recompile to a non-debug executable. But, still, it kind of defeats the purpose of having debug commands in the code if I can't run in debug mode. The idea was to benefit from breakpoints and debug output at the same time during some complex loops. So, again, it leads me back to the question of what I might need to check to understand why things are working normally for static strings but not for strings with runtime info, and if there's anything I can do about it?

Why don't you just use this:

void ab_Trace(const char *message) 
{
  OutputDebugString( message ); 
}