PS: the above globally changes the console's behavior and has the side 
effect that log calls made from unrelated JavaScript code will also no 
longer show the "source file". The clean way is probably to define the 
Module's "print" function by passing a respective object into the Module 
constuction function:

let in = {
print: function(t) { 
// suppress annoying "source file" info
setTimeout(console.log.bind(console, t)); // "lose" the original context
}
};



juergen...@gmail.com schrieb am Freitag, 11. August 2023 um 14:56:26 UTC+2:

> Thanks for the tip. The behavior actually seems to depend on 
> std::cerr/stderr.. when stdout is used instead then the stacktrace is gone 
> (i.e. works also in C).
>
> To then also get rid of the annoying "source file" info console.log has to 
> be replaced before the EMSCRIPTEN Module is instanciated, i.e. putting 
> something like the below into the respective file does the trick (and it 
> doesn't seem to have any negative effects on the scenarios where you 
> actually want to log an error with stacktrace):
>
> let origLog = console.log;
> console.log = function(t) { 
> setTimeout(origLog.bind(console, t)); // "lose" the original context
> };
>
> problem solved :-)
> mike.l...@googlemail.com schrieb am Freitag, 11. August 2023 um 14:15:43 
> UTC+2:
>
>>
>> I sometimes just want to print trace output from the C/C++ side and I do 
>> not care about the stack trace info in that scenario. I already do know 
>> exactly where the messages come from and the stack unnecessarily bloats the 
>> output by 1-2 orders of magnitude - sometimes slowing the browser to a 
>> crawl due to the amount of data, and unnecessarily complicating the actual 
>> use of the log data..
>>
>> How can EMSCRIPTEN's default impl of always including the stack info be 
>> overridden to just print my plain fprint messages? 
>>
>>
>> Instead of printf use std::cout << "your message" << yourObject << 
>> std::endl, if you are in C++. That only prints that message, nothing else 
>> (and does good formatting). I use that currently for debugging.
>>
>> Mike
>> -- 
>> www.soft-gems.net 
>>
>>

-- 
You received this message because you are subscribed to the Google Groups 
"emscripten-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to emscripten-discuss+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/emscripten-discuss/15ef311a-1b69-4f03-b35c-4d9404b3b28cn%40googlegroups.com.

Reply via email to