<commit_before>/* See license.txt for terms of usage */

FBL.ns(function() { with (FBL) {
// ************************************************************************************************


// ************************************************************************************************
// Console

var ConsoleAPI = 
{
    firebuglite: Firebug.version,
    
    xxx: function(o)
    {
        var rep = Firebug.getRep(o);
        var className = "";
        
        var panel = Firebug.DOM.getPanel();
        var toggles = {};
        
        var row = Firebug.Console.getPanel().panelNode.ownerDocument.createElement("div");
        var target = row;
        var object = o;
        
        row.className = "logRow" + (className ? " logRow-"+className : "");
        //row.innerHTML = message.join("");
        
        rep.tag.replace({domPanel: panel, toggles: toggles, object: object}, target);
        
        Firebug.Console.appendRow(row);
    },

    log: function()
    {
        return Firebug.Console.logFormatted(arguments, "");
    },
    
    debug: function()
    {
        return Firebug.Console.logFormatted(arguments, "debug");
    },
    
    info: function()
    {
        return Firebug.Console.logFormatted(arguments, "info");
    },
    
    warn: function()
    {
        return Firebug.Console.logFormatted(arguments, "warning");
    },
    
    error: function()
    {
        return Firebug.Console.logFormatted(arguments, "error");
    },
    
    assert: function(truth, message)
    {
        if (!truth)
        {
            var args = [];
            for (var i = 1; i < arguments.length; ++i)
                args.push(arguments[i]);
            
            Firebug.Console.logFormatted(args.length ? args : ["Assertion Failure"], "error");
            throw message ? message : "Assertion Failure";
        }
        
        return Firebug.Console.LOG_COMMAND;        
    },
    
    dir: function(object)
    {
        var html = [];
                    
        var pairs = [];
        for (var name in object)
        {
            try
            {
                pairs.push([name, object[name]]);
            }
            catch (exc)
            {
            }
        }
        
        pairs.sort(function(a, b) { return a[0] < b[0] ? -1 : 1; });
        
        html.push('<div class="log-object">');
        for (var i = 0; i < pairs.length; ++i)
        {
            var name = pairs[i][0], value = pairs[i][1];
            
            html.push('<div class="property">', 
                '<div class="propertyValueCell"><span class="propertyValue">');
                
            Firebug.Reps.appendObject(value, html);
            
            html.push('</span></div><div class="propertyNameCell"><span class="propertyName">',
                escapeHTML(name), '</span></div>'); 
            
            html.push('</div>');
        }
        html.push('</div>');
        
        return Firebug.Console.logRow(html, "dir");
    },
    
    dirxml: function(node)
    {
        var html = [];
        
        Firebug.Reps.appendNode(node, html);
        
        return Firebug.Console.logRow(html, "dirxml");
    },
    
    group: function()
    {
        return Firebug.Console.logRow(arguments, "group", Firebug.Console.pushGroup);
    },
    
    groupEnd: function()
    {
        return Firebug.Console.logRow(arguments, "", Firebug.Console.popGroup);
    },
    
    time: function(name)
    {
        Firebug.Console.timeMap[name] = new Date().getTime();
        
        return Firebug.Console.LOG_COMMAND;
    },
    
    timeEnd: function(name)
    {
        var timeMap = Firebug.Console.timeMap;
        
        if (name in timeMap)
        {
            var delta = new Date().getTime() - timeMap[name];
            Firebug.Console.logFormatted([name+ ":", delta+"ms"]);
            delete timeMap[name];
        }
        
        return Firebug.Console.LOG_COMMAND;
    },
    
    count: function()
    {
        return this.warn(["count() not supported."]);
    },
    
    trace: function()
    {
        var getFuncName = function getFuncName (f)
        {
            if (f.getName instanceof Function)
                return f.getName();
            if (f.name) // in FireFox, Function objects have a name property...
                return f.name;
            
            var name = f.toString().match(/function\s*(\w*)/)[1];
            return name || "anonymous";
        };
    
        var traceLabel = "Stack Trace";
        
        Firebug.Console.group(traceLabel);
        
        for (var fn = arguments.callee.caller; fn; fn = fn.caller)
        {
            var html = [ getFuncName(fn), "(" ];

            for (var i = 0, l = fn.arguments.length; i < l; ++i)
            {
                if (i)
                    html.push(", ");
                
                Firebug.Reps.appendObject(fn.arguments[i], html);
            }

            html.push(")");
            Firebug.Console.logRow(html, "stackTrace");
        }
        
        Firebug.Console.groupEnd(traceLabel);<commit_msg>Fixed problem with console.trace(), when tracing recursion.<commit_after>/* See license.txt for terms of usage */

FBL.ns(function() { with (FBL) {
// ************************************************************************************************


// ************************************************************************************************
// Console

var ConsoleAPI = 
{
    firebuglite: Firebug.version,
    
    xxx: function(o)
    {
        var rep = Firebug.getRep(o);
        var className = "";
        
        var panel = Firebug.DOM.getPanel();
        var toggles = {};
        
        var row = Firebug.Console.getPanel().panelNode.ownerDocument.createElement("div");
        var target = row;
        var object = o;
        
        row.className = "logRow" + (className ? " logRow-"+className : "");
        //row.innerHTML = message.join("");
        
        rep.tag.replace({domPanel: panel, toggles: toggles, object: object}, target);
        
        Firebug.Console.appendRow(row);
    },

    log: function()
    {
        return Firebug.Console.logFormatted(arguments, "");
    },
    
    debug: function()
    {
        return Firebug.Console.logFormatted(arguments, "debug");
    },
    
    info: function()
    {
        return Firebug.Console.logFormatted(arguments, "info");
    },
    
    warn: function()
    {
        return Firebug.Console.logFormatted(arguments, "warning");
    },
    
    error: function()
    {
        return Firebug.Console.logFormatted(arguments, "error");
    },
    
    assert: function(truth, message)
    {
        if (!truth)
        {
            var args = [];
            for (var i = 1; i < arguments.length; ++i)
                args.push(arguments[i]);
            
            Firebug.Console.logFormatted(args.length ? args : ["Assertion Failure"], "error");
            throw message ? message : "Assertion Failure";
        }
        
        return Firebug.Console.LOG_COMMAND;        
    },
    
    dir: function(object)
    {
        var html = [];
                    
        var pairs = [];
        for (var name in object)
        {
            try
            {
                pairs.push([name, object[name]]);
            }
            catch (exc)
            {
            }
        }
        
        pairs.sort(function(a, b) { return a[0] < b[0] ? -1 : 1; });
        
        html.push('<div class="log-object">');
        for (var i = 0; i < pairs.length; ++i)
        {
            var name = pairs[i][0], value = pairs[i][1];
            
            html.push('<div class="property">', 
                '<div class="propertyValueCell"><span class="propertyValue">');
                
            Firebug.Reps.appendObject(value, html);
            
            html.push('</span></div><div class="propertyNameCell"><span class="propertyName">',
                escapeHTML(name), '</span></div>'); 
            
            html.push('</div>');
        }
        html.push('</div>');
        
        return Firebug.Console.logRow(html, "dir");
    },
    
    dirxml: function(node)
    {
        var html = [];
        
        Firebug.Reps.appendNode(node, html);
        
        return Firebug.Console.logRow(html, "dirxml");
    },
    
    group: function()
    {
        return Firebug.Console.logRow(arguments, "group", Firebug.Console.pushGroup);
    },
    
    groupEnd: function()
    {
        return Firebug.Console.logRow(arguments, "", Firebug.Console.popGroup);
    },
    
    time: function(name)
    {
        Firebug.Console.timeMap[name] = new Date().getTime();
        
        return Firebug.Console.LOG_COMMAND;
    },
    
    timeEnd: function(name)
    {
        var timeMap = Firebug.Console.timeMap;
        
        if (name in timeMap)
        {
            var delta = new Date().getTime() - timeMap[name];
            Firebug.Console.logFormatted([name+ ":", delta+"ms"]);
            delete timeMap[name];
        }
        
        return Firebug.Console.LOG_COMMAND;
    },
    
    count: function()
    {
        return this.warn(["count() not supported."]);
    },
    
    trace: function()
    {
        var getFuncName = function getFuncName (f)
        {
            if (f.getName instanceof Function)
                return f.getName();
            if (f.name) // in FireFox, Function objects have a name property...
                return f.name;
            
            var name = f.toString().match(/function\s*([_$\w\d]*)/)[1];
            return name || "anonymous";
        };
        
        var wasVisited = function(fn)
        {
            for (var i=0, l=stack.length; i<l; i++)
            {
                if (stack[i] == fn)
                    return true;
            }
            
            return false;
        };
    
        var stack = [];
        
        var traceLabel = "Stack Trace";
        
        this.group(traceLabel);
        
        for (var fn = arguments.callee.caller; fn; fn = fn.caller)
        {
            if (wasVisited(fn)) break;
            
            stack.push(fn);
            
            var html = [ 
                "<div class='objectBox-function'>",
                getFuncName(fn), 
                "(" 
            ];

            for (var i = 0, l = fn.arguments.length; i < l; ++i)
            {
                if (i)
                    html.push(", ");
                
                Firebug.Reps.appendObject(fn.arguments[i], html);
            }

            html.push(")</div>");
            Firebug.Console.logRow(html, "stackTrace");
            //Firebug.Console.log(html);
        }
        
        this.groupEnd(traceLabel);
{'fraction_non_alphanumeric': 0.16926793013749536, 'fraction_numerical': 0.0019509476031215162, 'mean_word_length': 1.5204870053851558, 'pattern_counts': {'":': 2, '<': 38, '<?xml version=': 0, '>': 29, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 4}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7027397', 'n_tokens_mistral': 3038, 'n_tokens_neox': 2984, 'n_words': 574}