{"size": 1103, "ext": "js", "max_stars_repo_path": "customLog.js", "max_stars_repo_name": "mbychawski/distributed-chat", "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "customLog.js", "max_issues_repo_name": "mbychawski/distributed-chat", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "customLog.js", "max_forks_repo_name": "mbychawski/distributed-chat", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": null, "max_issues_count": null, "max_forks_count": null, "avg_line_length": 29.8108108108, "max_line_length": 75, "alphanum_fraction": 0.5775158658}
 /*
 * Copyright (C) 2015 Marcin Bychawski
 * All rights reserved.
 *
 * This software may be modified and distributed under the terms
 * of the BSD license.  See the LICENSE file for details.
 */
var minPriority = 1;
var colors = require('colors');

// priority - 0 is always displayed, greater number, less important message
exports.log = function(text, indent, priority, nodeNo) {
    if( indent === undefined ) indent = 0;
    if( priority === undefined ) priority = 0;
    nodeNoStr = (nodeNo !== undefined) ? 'NODE-'+nodeNo+': ' : '';

    if( priority <= minPriority ) {
        var strInd = '';
        for(var i = 0; i < indent; i++) {
            strInd += ' ';
        }
        text = strInd + nodeNoStr + text;

        switch(nodeNo) {
            case 0: text = text.yellow;  break;
            case 1: text = text.green;   break;
            case 2: text = text.magenta; break;
            case 2: text = text.magenta; break;
        }
        process.stdout.write('\r');
        console.log( text );
    }
}

exports.setMinPriority = function( newValue ) {
    minPriority = newValue;
}