Re: howto disable stack trace for console output of fprintf

2023-08-11 Thread juergen...@gmail.com
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.


Re: howto disable stack trace for console output of fprintf

2023-08-11 Thread juergen...@gmail.com
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/9e4207cf-9802-4ce1-a5ed-1fd9696eada4n%40googlegroups.com.


Re: howto disable stack trace for console output of fprintf

2023-08-11 Thread juergen...@gmail.com
aha!... using "stdout" instead of "stderr" always gets rid of the stack 
trace! (I can live with that..)  now the only remaining question is how to 
get EMSCRIPTEN to use my replaced (see above) console.log rather than the 
original one...

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

> thanks for the tip. that is indeed an improvement for the C++ case - 
> unfortunately it doesn't help for my current C project. Also I'd like to 
> completely get rid of the useless "source file" info (since it is a 
> nuisance having to edit that out first when using the logs), something that 
> I'd handle in the plain JavaScript context using something like this:
>
> function disableLogSourceDisplay() {
> var origLog = console.log;
>
> console.log = function (s1) { 
> setTimeout(origLog.bind(console, s1)); // "lose" the original context
> };
> }
> disableLogSourceDisplay(); 
>
>
>

-- 
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/d4cc097c-ccdd-4001-a715-e7c174b2c4b0n%40googlegroups.com.


Re: howto disable stack trace for console output of fprintf

2023-08-11 Thread juergen...@gmail.com
thanks for the tip. that is indeed an improvement for the C++ case - 
unfortunately it doesn't help for my current C project. Also I'd like to 
completely get rid of the useless "source file" info (since it is a 
nuisance having to edit that out first when using the logs), something that 
I'd handle in the plain JavaScript context using something like this:

function disableLogSourceDisplay() {
var origLog = console.log;

console.log = function (s1) { 
setTimeout(origLog.bind(console, s1)); // "lose" the original context
};
}
disableLogSourceDisplay(); 


-- 
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/889ef6e1-e8de-470f-841c-e769a0edfdf2n%40googlegroups.com.


Re: howto disable stack trace for console output of fprintf

2023-08-11 Thread 'Mike Lischke' via emscripten-discuss
> 
> 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/A4EBC6FD-6F59-40BA-96C4-4799BC92B16C%40googlemail.com.