properly use console.log on the web
This commit is contained in:
Родитель
350fa1956b
Коммит
e91161817c
|
@ -330,18 +330,7 @@ LibraryManager.library = {
|
|||
output.buffer.push(String.fromCharCode(val));
|
||||
}
|
||||
};
|
||||
if (!output.printer) {
|
||||
if (typeof print == 'function') {
|
||||
// Either console or custom print function defined.
|
||||
output.printer = print;
|
||||
} else if (console && typeof console.log == 'function') {
|
||||
// Browser-like environment with a console.
|
||||
output.printer = console.log;
|
||||
} else {
|
||||
// Fallback to a harmless no-op.
|
||||
output.printer = function() {};
|
||||
}
|
||||
}
|
||||
if (!output.printer) output.printer = print;
|
||||
if (!output.buffer) output.buffer = [];
|
||||
if (!error) error = output;
|
||||
|
||||
|
|
|
@ -655,8 +655,10 @@ Module['String_copy'] = String_copy;
|
|||
|
||||
// Tools
|
||||
|
||||
if (typeof print === 'undefined') {
|
||||
this['print'] = console.log; // we are on the web
|
||||
if (typeof console === 'object' && typeof console.log === 'function') {
|
||||
this['print'] = function(x) { console.log(x) }; // web console
|
||||
} else if (typeof print === 'undefined') {
|
||||
this['print'] = function(){}; // harmless no-op
|
||||
}
|
||||
|
||||
// This processes a JS string into a C-line array of numbers, 0-terminated.
|
||||
|
|
Загрузка…
Ссылка в новой задаче