Restoring console.log

Updated . Posted . Visible to the public.

To do this permanently by altering your JS files, comment out this code on line 637 of js/varien/js/js:

if (!("console" in window) || !("firebug" in console))
{
    var names = ["log", "debug", "info", "warn", "error", "assert", "dir", "dirxml",
    "group", "groupEnd", "time", "timeEnd", "count", "trace", "profile", "profileEnd"];

    window.console = {};
    for (var i = 0; i < names.length; ++i)
        window.console[names[i]] = function() {}
}

Or, you could paste this into your layout somewhere (thanks to Alan Storm Show archive.org snapshot for this):

<default>
    <reference name="content">
        <block type="core/text" name="fix.console" as="fix.console">
            <action method="setText">
                <text><![CDATA[<script type="text/javascript">
                    iframe = document.createElement('iframe');
                    iframe.style.display = 'none';
                    document.getElementsByTagName('body')[0].appendChild(iframe);
                    window.console = iframe.contentWindow.console;
                    console.firebug = "faketrue";                   
                </script>]]></text>
            </action>
        </block>
    </reference>
</default>

To do this as a one-off, you can copy and paste this code into the console of your browser window (also thanks to Alan Storm Show archive.org snapshot for this):

iframe = document.createElement('iframe');
iframe.style.display = 'none';
document.getElementsByTagName('body')[0].appendChild(iframe);
window.console = iframe.contentWindow.console;
console.firebug = "faketrue"; 

Mike Whitby
Last edit
Posted by Mike Whitby to Magento (2012-03-20 13:04)