Ejemplo n.º 1
0
    function val (name, value) {
        
        var text = util.format("DEBUG: (%s) %s", utils.getType(value), name);

        output(text, value);

    };
Ejemplo n.º 2
0
    this.register = function (newCommand) {
        
        // if the first argument is an Array
        if (Array.isArray(newCommand)) {
            newCommand.forEach(addCommand);
        } 

        // or if the first argument is an Object literal
        else if (utils.getType(newCommand) === 'object') {
            addCommand(newCommand);
        }

        // otherwise, bad input was provided
        else {
            throw new Error("arg 0: must Object or Array of Objects!");
        }
    };
Ejemplo n.º 3
0
    this.stop = function (done) {

        this.emit('stopping');

        if (utils.getType(done) === 'function') {
            this.on('stopped', done);
        }

        clients.forEach(function (client) {
            client.end('received shutdown signal!\n');
        });

        server.close(function () {
            self.emit('stopped');
        });

    };
Ejemplo n.º 4
0
    function output (text, value) {
        var marker = '';

        for (var i = 0; i < process.stdout.columns; i +=1 ) {
            marker += '-';
        }

        if (config.marker) {
            console.log(marker);
        }

        console.log(text);

        // if a value was provided as an argument
        if ('1' in arguments) {
            // some types don't show up when logged to console, so we'll convert 
            // them to strings for better readability
            switch (utils.getType(value)) {
                case 'boolean':
                case 'number':
                    value = String(value);
                break;

                case 'object':
                    if (value === null) {
                        value = String(value);
                    }
                break;
                
            }

            console.log(value);
        }

        if (config.printStack) {
            console.trace();
        }    

        if (config.marker) {
            console.log(marker);
        }

    };
Ejemplo n.º 5
0
    this.start = function (done) {
        this.emit('starting');

        // if socket path was defined, listen on that socket
        if (config.socket) {
            server.listen(config.socket);
        } 

        // otherwise, we'll use TCP port and address from config
        else {
            server.listen(config.port, config.address);
        }

        if (utils.getType(done) === 'function') {
            this.on('ready', done);
        }

        this.emit('ready');

        return true;
    };