lib/Plugins.class.js
/**
     * Creates an instance of the given type and stores it under the name.
     * @param {function|string} type    The name of the type of plugin to create.
     * @param {string} [id=config]      The id to assign to the plugin. Note that {@link Configurator}s ignore the value
     *                                  and instead assign the type as id.
     * @param {Object} config           The configuration for the plugin you want to create an instance of
     * @returns {Appender|Configurator|Processor} the instance just created.
     */
Creates an instance of the given type and stores it under the name.
@param {function|string} type    The name of the type of plugin to create.
@param {string} [id=config]      The id to assign to the plugin. Note that  Configurators ignore the value
and instead assign the type as id.
Creates an instance of the given type and stores it under the name . @param { function|string } type The name of the type of plugin to create . @param { string } [ id = config ] The id to assign to the plugin . Note that Configurators ignore the value and instead assign the type as id .
createInstance(type, id, config) {
        if (_.isFunction(type)) {
            type = type.name;
        }
        if (_.isObject(id)) {
            config = id;
        }
        if (this.registered.appenders[type]) {
            this.instances.appenders[id] = new this.registered.appenders[type](id);
            this.instances.appenders[id].configuration = config;
            this.emit('create', this.instances.appenders[id]);
            return this.instances.appenders[id];
        }
        if (this.registered.processors[type]) {
            this.instances.processors[id] = new this.registered.processors[type](id);
            this.instances.processors[id].configuration = config;
            this.emit('create', this.instances.processors[id]);
            return this.instances.processors[id];
        }
        if (this.registered.configurators[type]) {
            this.instances.configurators[type] = new this.registered.configurators[type](type);
            this.instances.configurators[type].configuration = config;
            this.emit('create', this.instances.configurators[type]);
            return this.instances.configurators[type];
        }
        throw new Error(`Can't create instance of type ${type}`);
    }
createInstance ( type , id , config ) { if ( _ . isFunction ( type ) ) { type = type . name ; } if ( _ . isObject ( id ) ) { config = id ; } if ( this . registered . appenders [ type ] ) { this . instances . appenders [ id ] = new this . registered . appenders [ type ] ( id ) ; this . instances . appenders [ id ] . configuration = config ; this . emit ( 'create' , this . instances . appenders [ id ] ) ; return this . instances . appenders [ id ] ; } if ( this . registered . processors [ type ] ) { this . instances . processors [ id ] = new this . registered . processors [ type ] ( id ) ; this . instances . processors [ id ] . configuration = config ; this . emit ( 'create' , this . instances . processors [ id ] ) ; return this . instances . processors [ id ] ; } if ( this . registered . configurators [ type ] ) { this . instances . configurators [ type ] = new this . registered . configurators [ type ] ( type ) ; this . instances . configurators [ type ] . configuration = config ; this . emit ( 'create' , this . instances . configurators [ type ] ) ; return this . instances . configurators [ type ] ; } throw new Error ( ` ${ type } ` ) ; }
Creates an instance of the given type and stores it under the name.
Creates an instance of the given type and stores it under the name .