I wonder If anyone can help me with this:
In developer mode, I can open the “Console” from the “debug” menu. Here I see logging at Error, Warning, and Info levels. However, I cannot find anywhere in the documentation how this logging is made. Searches for “console” send me to the JavaScript console, and “logging” starts with pneumatic systems and then into models with loads of XML. Nothing in the WASM or SimConnect APIs that I can find either.
It could be as simple as printing to stdout or stderr, but that just gives me two levels, while there are at least three.
Cheers,
Bert
Hello @BenkeiBuddy,
In WASM, if you want to send some piece of information (for debugging and such) to the sim’s console, you can use the C fprintf function in C++. The aforementioned function requires you to specify whether to send to stdout (Info category on the console) or stderr (Error category on the console).
For example:
fprintf(stdout, "Gauge successfully initialized.");
The message above is sent to the Info (blue icon) category.
fprintf(stderr, "SimConnect failed to initialize.");
The message above is sent to the Error (red icon) category.
Then, when checking on the Console output in the sim, you can find it as:
[WASM] [<yourwasmmodule>.wasm] <Your message>
Now, if you also want the messages to appear only in Debug mode and not in production (Release), you can use the #ifdef directive, like this:
#ifdef _DEBUG
fprintf(stderr, "Something went wrong.");
#endif // _DEBUG
Just be sure that the _DEBUG define macro is set in the WASM project properties. It normally is on MSFS WASM projects, but check before just in case.
Regards,
Carlos Daniel González Gómez
NextGen Simulations
Hey Carlos,
thank you for your reply. As my question indicated, I was kind of hoping for an indication how to get “Warning” level messages as well. As the documentation indicates, there are three levels. Also, the Console talks about being able to show “details”.
Bert
Hello Bert (@BenkeiBuddy),
It is pretty understandable what you were asking before, but in WASM in the sim, and AFAIK, you either send to info or error, through the stdout or stderr streams in the fprintf function. There is no possibility to send to the warning category, based on my knowledge.
The same message you send from the fprintf function is seen on the description field of the Details pane, especially useful if the message’s string length is higher than what the UI’s list field can render.
Regards,
Carlos Daniel González Gómez
NextGen Simulations