<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[LoggerInterface API - reading all lines from the console]]></title><description><![CDATA[<p dir="auto">Based on a previous post, I implemented the example to read all the lines from the console.<br />
"This example accesses the default logger and gets all displayed lines".</p>
<p dir="auto">I changed the microsdk example to implement the function.<br />
Below the Execute() part of the command plugin.</p>
<p dir="auto">However, it does not show any lines in the console.</p>
<p dir="auto">Also, when I change <code>DiagnosticOutput("Line: @", line._str);</code> to <code>ApplicationOutput("Line: @", line._str);</code> cinema 'hangs' on the line above <code>userLoggerType.Iterate([](maxon::LoggerLine&amp; line) -&gt; maxon::Result&lt;void&gt;</code></p>
<p dir="auto">Could it be that I did not activate the diagnostic output?</p>
<p dir="auto">Manual: "The output is visible in debug builds or in a release build when the debug console with diagnostic output is activated"</p>
<pre><code>	virtual Bool Execute(BaseDocument* doc)
	{
		iferr_scope_handler
		{
			// if an error occurred, show a pop-up message
			const maxon::String errString = err.ToString(nullptr);
			::MessageDialog(errString);
			return false;
		};

		//###########################################
		// This example accesses the default logger and gets all displayed lines.
		// get default logger

		ApplicationOutput("This example accesses the default logger and gets all displayed lines.");
		
		const maxon::LoggerRef defaultLogger = maxon::Loggers::Default();
		for (const auto&amp; logger : defaultLogger.GetLoggerTypes())
		{
			const maxon::LoggerTypeRef loggerType = logger.GetFirst();  // get first element of the pair
			if (loggerType.IsInstanceOf&lt;maxon::UserLoggerTypeRef&gt;())
			{
				const maxon::UserLoggerTypeRef userLoggerType = maxon::Cast&lt;maxon::UserLoggerTypeRef&gt;(loggerType);
				// iterate over all lines sent to the logger
				userLoggerType.Iterate([](maxon::LoggerLine&amp; line) -&gt; maxon::Result&lt;void&gt;
				{
					DiagnosticOutput("Line: @", line._str);
					//ApplicationOutput("Line: @", line._str);
					return maxon::OK;
				}) iferr_return;
			}
		}
		

		return true;
	}
</code></pre>
]]></description><link>http://developers.maxon.net/forum/topic/11019/loggerinterface-api-reading-all-lines-from-the-console</link><generator>RSS for Node</generator><lastBuildDate>Tue, 16 Jun 2026 22:46:47 GMT</lastBuildDate><atom:link href="http://developers.maxon.net/forum/topic/11019.rss" rel="self" type="application/rss+xml"/><pubDate>Fri, 21 Sep 2018 08:45:57 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to LoggerInterface API - reading all lines from the console on Mon, 24 Sep 2018 12:38:52 GMT]]></title><description><![CDATA[<p dir="auto">Great, thank you for the great explanation, especially of the loop!<br />
I will give it a try.</p>
<p dir="auto">-Pim</p>
]]></description><link>http://developers.maxon.net/forum/post/55793</link><guid isPermaLink="true">http://developers.maxon.net/forum/post/55793</guid><dc:creator><![CDATA[pim]]></dc:creator><pubDate>Mon, 24 Sep 2018 12:38:52 GMT</pubDate></item><item><title><![CDATA[Reply to LoggerInterface API - reading all lines from the console on Mon, 24 Sep 2018 09:38:33 GMT]]></title><description><![CDATA[<p dir="auto">Hello,</p>
<p dir="auto">as you have discovered, <code>ApplicationOutput()</code> sends messages to the default (GUI) console window.</p>
<p dir="auto"><code>DiagnosticOutput()</code> sends messages to the IDE console window. This has nothing to do with <em>g_alloc=debug</em>.</p>
<p dir="auto">See "<a href="https://developers.maxon.net/docs/cpp/2023_2/page_maxonapi_debug.html#page_maxonapi_debug_messages" target="_blank" rel="noopener noreferrer nofollow ugc">Printing Debug Messages</a>".</p>
<p dir="auto">So what you want to do is to access the content of the default logger (<code>Loggers::Default()</code>) and write that content back into that very same default logger (<code>ApplicationOutput()</code>).</p>
<p dir="auto">When you use <code>ApplicationOutput()</code> in the iterator, you create new line every time your access a line. This is of course a perfect recipe for an recursive, infinite loop.</p>
<p dir="auto">If you want to print the content of the default logger back to the default logger, you have to store the content temporarily. Something like this:</p>
<pre><code>// temp array
maxon::BaseArray&lt;maxon::String&gt; lines;

// iterate over all lines of the logger
userLoggerType.Iterate([&amp;lines](maxon::LoggerLine&amp; line) -&gt; maxon::Result&lt;void&gt;
{
  iferr_scope;
  // store line
  lines.Append(line._str) iferr_return;
  return maxon::OK;
}) iferr_return;

// print back to default logger
for (const maxon::String&amp; line : lines)
{
  ApplicationOutput("Message: @", line);
}
</code></pre>
<p dir="auto">best wishes,<br />
Sebastian</p>
]]></description><link>http://developers.maxon.net/forum/post/55790</link><guid isPermaLink="true">http://developers.maxon.net/forum/post/55790</guid><dc:creator><![CDATA[s_bach]]></dc:creator><pubDate>Mon, 24 Sep 2018 09:38:33 GMT</pubDate></item><item><title><![CDATA[Reply to LoggerInterface API - reading all lines from the console on Fri, 21 Sep 2018 15:40:32 GMT]]></title><description><![CDATA[<p dir="auto">I guess I found some answers:</p>
<p dir="auto">DiagnosticOutput() uses the IDE Console, so I set 'g_alloc=debug', which then showed the information in the VS C++ output window.</p>
<p dir="auto">I am still struggling with outputting the the console lines to the application console or to a text file.</p>
<p dir="auto">When I add the the line <code>ApplicationOutput("Line: @", line._str);</code> after the <code>DiagnosticOutput()</code> line, I get the following message in the VC Output window (the IDE Console).</p>
<p dir="auto">"Socket closed without SSL shutdown handshake [network_ip_ssl_impl.cpp(854)]<br />
Was not able to create new user".</p>
]]></description><link>http://developers.maxon.net/forum/post/55781</link><guid isPermaLink="true">http://developers.maxon.net/forum/post/55781</guid><dc:creator><![CDATA[pim]]></dc:creator><pubDate>Fri, 21 Sep 2018 15:40:32 GMT</pubDate></item></channel></rss>