<commit_before>module.exports = {
    onPhantomPageCreate: function(phantom, req, res, next) {
        req.prerender.page.set('onConsoleMessage', function(msg) {
            console.log(msg);
        });

        next();
    }
}<commit_msg>Better logging<commit_after>module.exports = {
    onPhantomPageCreate: function(phantom, req, res, next) {
        req.prerender.page.set('onConsoleMessage', function(msg) {
            console.log('[CONSOLE] ' + msg);
        });

        req.prerender.page.set('onResourceError', function(resourceError) {
            console.log('[RESOURCE ERROR] Unable to load resource (#' + resourceError.id + ' URL:' + resourceError.url + ')');
            console.log('[RESOURCE ERROR] Error Code: ' + resourceError.errorCode + '. Description: ' + resourceError.errorString);
        });

        req.prerender.page.set('onError', function(msg, trace) {
            var msgStack = ['[ERROR] ' + msg];

            if (trace && trace.length) {
                msgStack.push('[TRACE]');
                trace.forEach(function(t) {
                    msgStack.push(' -> ' + t.file + ': ' + t.line + (t.function ? ' (in function "' + t.function +'")' : ''));
                });
            }

            console.error(msgStack.join('\n'));
        });

        next();
    }
}
{'fraction_non_alphanumeric': 0.1675592960979342, 'fraction_numerical': 0.0, 'mean_word_length': 2.144230769230769, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 4, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, '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': '5682170', 'n_tokens_mistral': 398, 'n_tokens_neox': 375, 'n_words': 60}