<commit_before>const GoodSentry = require('./sentry');

const GoodPlugin = {
    register(server, config, next) {
        const reporters = {};

        // Default squeeze filter
        const squeeze = {
            module: 'good-squeeze',
            name: 'Squeeze',
            args: [{log: '*'}]
        };

        // Console reporter
        if (process.env.NODE_ENV !== 'production') {
            reporters.console = [
                squeeze,
                {module: 'good-console'},
                'stdout'
            ];
        }

        // Sentry reporter
        if (config.sentry && config.sentry.dsn) {
            reporters.sentry = [
                squeeze,
                {
                    module: GoodSentry,
                    args: [{
                        server,
                        dsn: config.sentry.dsn,
                        config: config.sentry,
                    }]
                }
            ];
        }

        server.register({
            register: require('good'),
            options: {reporters}
        }, (err) => {
            if (err) console.error(err);
            if (next) next();
        });
    }
};

GoodPlugin.register.attributes = {
    name: 'bak-good',
};

module.exports = GoodPlugin;<commit_msg>enable good-console if no sentry configured<commit_after>const GoodSentry = require('./sentry');

const GoodPlugin = {
    register(server, config, next) {
        const reporters = {};

        // Default squeeze filter
        const squeeze = {
            module: 'good-squeeze',
            name: 'Squeeze',
            args: [{log: '*'}]
        };

        // Sentry reporter
        if (config.sentry && config.sentry.dsn) {
            reporters.sentry = [
                squeeze,
                {
                    module: GoodSentry,
                    args: [{
                        server,
                        dsn: config.sentry.dsn,
                        config: config.sentry,
                    }]
                }
            ];
        }

        // Console reporter
        if (process.env.NODE_ENV !== 'production' && !reporters.sentry) {
            reporters.console = [
                squeeze,
                {module: 'good-console'},
                'stdout'
            ];
        }

        server.register({
            register: require('good'),
            options: {reporters}
        }, (err) => {
            if (err) console.error(err);
            if (next) next();
        });
    }
};

GoodPlugin.register.attributes = {
    name: 'bak-good',
};

module.exports = GoodPlugin;
{'fraction_non_alphanumeric': 0.12331924702266615, 'fraction_numerical': 0.0, 'mean_word_length': 1.1170731707317074, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, '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': '7178236', 'n_tokens_mistral': 702, 'n_tokens_neox': 667, 'n_words': 131}