<commit_before>const DiscordPayload = require('./DiscordPayload');
const camel = require('camelcase');

class BaseProvider {
    constructor() {
        this.payload = new DiscordPayload();
    }

    async parse(req) {
        this.req = req;
        this.body = req.body;

        let type = 'parseData';
        if (typeof this['getType'] !== 'undefined') {
            type = await this['getType']();
        }
        type = BaseProvider.formatType(type);

        if (typeof this[type] !== 'undefined') {
            await this[type]();
        }

        return this.payload.getData();
    }

    static formatType(type) {
        type = type.replace(/:/, '_'); // needed because of BitBucket
        return camel(type);
    }
}

module.exports = BaseProvider;<commit_msg>Adding log to BaseProvider in order to monitor recent unexpected crashes.<commit_after>const DiscordPayload = require('./DiscordPayload');
const camel = require('camelcase');

class BaseProvider {
    constructor() {
        this.payload = new DiscordPayload();
    }

    async parse(req) {
        this.req = req;
        this.body = req.body;

        let type = 'parseData';
        if (typeof this['getType'] !== 'undefined') {
            type = await this['getType']();
        }
        type = BaseProvider.formatType(type);

        if (typeof this[type] !== 'undefined') {
            console.log('[' + (new Date()).toUTCString() + '] Calling ' + type + '() in ' + this.constructor.name + ' provider.')
            await this[type]();
        }

        return this.payload.getData();
    }

    static formatType(type) {
        type = type.replace(/:/, '_'); // needed because of BitBucket
        return camel(type);
    }
}

module.exports = BaseProvider;
{'fraction_non_alphanumeric': 0.14759725400457666, 'fraction_numerical': 0.0, 'mean_word_length': 2.3, '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': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '472015', 'n_tokens_mistral': 494, 'n_tokens_neox': 486, 'n_words': 117}