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

define([
    "fbtrace/trace",
],
function(FBTrace) {

// ********************************************************************************************* //
// Constants

const Cc = Components.classes;
const Ci = Components.interfaces;
const Cu = Components.utils;

const consoleService = Cc["@mozilla.org/consoleservice;1"].getService(Ci.nsIConsoleService);

const WARNING_FLAG = Ci.nsIScriptError.warningFlag;

// ********************************************************************************************* //
// Trace Window Implementation

var TraceErrorListener =
{
    startObserving: function()
    {
        if (this.isObserving)
            return;

        if (consoleService)
            consoleService.registerListener(this);

        this.isObserving = true;
    },

    stopObserving: function()
    {
        if (!this.isObserving)
            return;

        if (consoleService)
            consoleService.unregisterListener(this);

        this.isObserving = false;
    },

    // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
    // extends consoleListener

    observe: function(object)
    {
        // Query interface (to access 'flags')
        var ScriptError = object instanceof Ci.nsIScriptError;

        // Ignore warnings
        if (object.flags & WARNING_FLAG)
            return;

        FBTrace.sysout("Console Service ERROR " + object, object);
    },
};

// ********************************************************************************************* //
// Registration

return TraceErrorListener;

// ********************************************************************************************* //
});
<commit_msg>FBTrace: better display of Fx console error messages<commit_after>/* See license.txt for terms of usage */

define([
    "fbtrace/trace",
],
function(FBTrace) {

// ********************************************************************************************* //
// Constants

const Cc = Components.classes;
const Ci = Components.interfaces;
const Cu = Components.utils;

const consoleService = Cc["@mozilla.org/consoleservice;1"].getService(Ci.nsIConsoleService);

const WARNING_FLAG = Ci.nsIScriptError.warningFlag;

// ********************************************************************************************* //
// Trace Window Implementation

var TraceErrorListener =
{
    startObserving: function()
    {
        if (this.isObserving)
            return;

        if (consoleService)
            consoleService.registerListener(this);

        this.isObserving = true;
    },

    stopObserving: function()
    {
        if (!this.isObserving)
            return;

        if (consoleService)
            consoleService.unregisterListener(this);

        this.isObserving = false;
    },

    // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
    // extends consoleListener

    observe: function(object)
    {
        // Query interface (to access 'flags')
        var ScriptError = object instanceof Ci.nsIScriptError;

        // Ignore warnings
        if (object.flags & WARNING_FLAG)
            return;

        var message = (object.message ? object.message : object);
        FBTrace.sysout("Console Service ERROR " + message, object);
    },
};

// ********************************************************************************************* //
// Registration

return TraceErrorListener;

// ********************************************************************************************* //
});
{'fraction_non_alphanumeric': 0.3169111541655134, 'fraction_numerical': 0.0005535566011624688, 'mean_word_length': 3.020022246941046, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 14, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '366285', 'n_tokens_mistral': 940, 'n_tokens_neox': 883, 'n_words': 170}