<commit_before>var path = require('path');
var filter = require('./pluginhelper');

module.exports = function(sails) {
    return {
        initialize: function(cb) {
            sails.after('hook:app:loaded', function() {
                var plugins = filter(sails.config.plugins);
                var waiting = [];
                plugins.forEach(function(plugin) {
                    waiting.push(function(callback) {
                        sails.log.info('Loading plugin ' + plugin.name + ' ...');
                        var pluginMain;
                        if(plugin.source === 'npm') {
                            pluginMain = require(plugin.name);
                        } else if(plugin.source === 'local') {
                            pluginMain = require(path.join(sails.config.rootPath, plugin.path));
                        }

                        var logCallback = function() {
                            sails.emit('plugin:' + plugin.name + ':loaded');
                            sails.log.info('Finished loading ' + plugin.name + '.');
                            callback();
                        };

                        sails.emit('plugin:' + plugin.name + ':init');
                        pluginMain(sails.chat, sails.app, logCallback);
                    });
                });

                async.parallel(waiting, function(err, result) {
                    if(err)
                        sails.log.error(err);

                    sails.log.info('Loaded ' + plugins.length + ' plugin(s).');
                    if(!sails.config.chat.disabled) {
                        sails.log.info('Connecting to chat ...');
                        sails.chat.run();
                    } else {
                        sails.log.info('Chat is disabled.');
                    }
                    cb();
                });
            });
        }<commit_msg>Small log and QoL improvements in plugin loading.<commit_after>var path = require('path');
var filter = require('./pluginhelper');

module.exports = function(sails) {
    return {
        loadedPlugins: [],

        initialize: function(cb) {
            var self = this;
            sails.after('hook:app:loaded', function() {
                var plugins = filter(sails.config.plugins);
                var waiting = [];
                plugins.forEach(function(plugin) {
                    waiting.push(function(callback) {
                        sails.log.info('Loading plugin `' + plugin.name + '`` ...');
                        var pluginMain;
                        if(plugin.source === 'npm') {
                            pluginMain = require(plugin.name);
                        } else if(plugin.source === 'local') {
                            pluginMain = require(path.join(sails.config.rootPath, plugin.path));
                        }

                        var logCallback = function() {
                            self.loadedPlugins.push(plugin);
                            sails.emit('plugin:' + plugin.name + ':loaded');
                            sails.log.info('Finished loading `' + plugin.name + '`.');
                            callback();
                        };

                        sails.emit('plugin:' + plugin.name + ':init');
                        pluginMain(sails.chat, sails.app, logCallback);
                    });
                });

                async.parallel(waiting, function(err, result) {
                    if(err)
                        sails.log.error(err);

                    sails.log.info('Loaded ' + self.loadedPlugins.length + ' plugin(s).');
                    if(!sails.config.chat.disabled) {
                        sails.log.info('Connecting to chat ...');
                        sails.chat.run();
                    } else {
                        sails.log.info('Chat is disabled.');
                    }
                    cb();
                });
            });
        }
{'fraction_non_alphanumeric': 0.12663975782038345, 'fraction_numerical': 0.0, 'mean_word_length': 1.0629552549427679, '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': '794378', 'n_tokens_mistral': 958, 'n_tokens_neox': 890, 'n_words': 150}