how to print log in flutter windows vc++ code? - windows

I write flutter to write a windows software, so I want to add same logs which shows in console in fultter windows vc++ code, I used printf and std::out to print logs, but android studio console not any print log, how to add logs in flutter windows vc++ code?

If you simply want to print text to the console you can use
print('Text').
But if you want to access the advanced features of the DevTools console you need to use the Console class from
dart:html: Console.log('Text')
Example:-
Use print() to print a string to the console of your browser:
import 'dart:html';
main() {
var value = querySelector('input').value;
print('The value of the input is: $value');
}

Related

Way to print message to debug output with Visual Studio CppUnitTestFramework

Is there a way to print messages to output window with CppUnitTestFramework in Visual Studio.
There is TRACE() function to display messages from program in the debugger Output window in MFC.
I want to know whether that kind of function exists or not with CppUnitTestFramework.
The Logger class in the CppUnitTestFramework namespace has two simple functions for this:
Logger::WriteMessage(const wchar_t* message);
Logger::WriteMessage(const char* message);
In the VS IDE, the output can be seen in the "Tests" console output window and can also by clicking the "Output" link seen in the detail panel at the bottom of the Test Explorer.
On a build server the message will appear in the log for the test phase.

How do I write to the CommandPrompt from Windows GUI?

Operating Environment: Windows 7, Visual Studio 2010, CLR GUI.
So I've been given the unglorious task of enhancing a GUI application that is started from a command prompt. Because it is. Because poor design decisions by previous implementers. Anyway, it launches one of several GUIs depending upon the input arguments.
I'd like to be able to print back to the same command prompt window if (when) the user types something that the code doesn't understand.
Here's what I've tried (none of which output anything):
int main( array<System::String^>^ args )
{
Application::EnableVisualStyles();
Application::SetCompatibleTextRenderingDefault(false);
OutputDebugString("hello");
Trace::WriteLine("hello");
Debug::Trace::WriteLine("hello");
Console::WriteLine("hello");
std::cout << "hello";
printf("hello");
return 0;
}
Thanks in advance!
Update: I don't want to use AllocConsole(), as that opens a new console that disappears along with all of the data when the application exits. Similarly, a pop-up message box won't work. I'm looking for a way to make the output persistent.
The only way I can get output from the application to date is via a message box (non-persistent) or opening a new console that disappears when the application exits (via AllocConsole() ). And I'm running from a command prompt, not the debugger's "Play" button.
Update
Why the down-vote for not doing research? I spent a day trying to solve this, looking through dozens of posts trying to find a solution, and to date I've found others looking for the same answer, but not finding it. AllocConsole() or changing the project type is always the solution, but neither is a solution for me.
Update
I added the "full code", which is the 2 statements. THAT IS ALL THE CODE. So simple. I'm skipping the start of the GUI because I don't care about that right now, I just want it to print back to the console where the application was started. The most basic HelloWorld. If there are project settings I need to post, I don't know which ones would be relevant. This is where I want to print to the console, before the GUI is ever up. I can't show the GUI if there is an error in the user input.
Right click on the project, select Properties
Under Linker -> System, Change Subsystem from Windows to Console.
A Windows subsystem application cannot write to console, but by changing the subsystem to Console (which can write to the calling console), the Form part of the application can still work (tested in Visual Studio 2010).

See VSTO console output without using a console application

I've been trying to step through example code that I've found and much of it uses Console.WriteLine which doesn't seem to work unless I start over with a new console application. How can I make this work in an existing application that wasn't initially set up a as a console app?
In a VSTO application, you likely have an app which is not a "console enabled" application. And if there is not console window in your application, then by default the strings you write using Console.WriteLine() are simply discarded.
You should use another function: Debug.WriteLine(), instead of Console.WriteLine. That way, the output will be available in your Visual Studio environment (when application is ran in 'debug' mode):
either in the "immediate window" tab (Visual Studio => Menu Debug => Windows => Immediate)
or in the "output" tab, when you choose "Debug" in the combobox "Show output from" (Visual Studio => Menu View => Other Windows => Output)
If you absolutely need to use Console.WriteLine() (because for example this is used by a third party lib of your project), you can override the default output of this function with Console.SetOut, which accepts a StreamWriter as parameter. For example, to output the logs in a file, you can put in application startup:
logFile = new System.IO.StreamWriter("C:/myLogs.txt");
Console.SetOut(logFile);

Where my log statement is printing on Mac?

I have an firefox extension with the name myjavascriptfile.js,As I am new to this addon concepts,just I want to debug this script.So I am using the following statements in this file like
function LOG(text)
{
var consoleService = Components.classes["#mozilla.org/consoleservice;1"].getService(Components.interfaces.nsIConsoleService);
consoleService.logStringMessage(text);
}
observe: function(subject, topic, data)
{
LOG("observe called ");
}
I know this observe is getting called but I dont know where to see my log message.can some one tell me Where it is printing?
Please help.
That text goes to the Error Console. You might need to go to about:config and change devtools.errorconsole.enabled preference to true - the Error Console was removed from the menus by default while ago (strangely enough, I could still see it even without this pref). I think that on OS X you can still open the Error Console via Tools / Web Developer menu, on Windows you have to click the Firefox button and choose Web Developer menu there. Alternatively, Command-Shift-J should do as well.

Win32 Application Console Output?

When developing a Win32 Application (non-console application) in Visual Studio 2005, is there any way to get the same sort of output as you do from the console?
For instance, say I want to see log statements (such as I would with cout in a console application) to trace the path my program has taken in the code.
My first thought would be that this could be done through the Output tab selecting something from its "Show output from:" dropdown, when debugging but I don't know what API I need to do this...
For example say I had the following in my windows application and wanted to know when the following function enters and exits writing the result to the Visual Studio window above.
void someFunction(void)
{
Win32APIConsoleLog("BEGIN: someFunction()");
// ...
Win32APIConsoleLog("END: someFunction()");
}
Is this possible? And if so, what what libraries do I need to include and what function calls do I need to make to write out to the console window?
OutputDebugString.
I assume that you want to write to the debug console, since that's what your screenshot shows. OutputDebugString is a nop when no debugger is attached, but it allows you to log whatever you want to the debugger's output.
OutputDebugStringW(L"This will go to the output.\n");
// or
OutputDebugString("This will go to the output.\n");

Resources