'use strict';

var path = require('path');

var level = 'info';

module.exports = {

    /**
     * Generic log function for printing the logs
     * @param _level Level of debug
     * @param _msg Message to print
     */
    log: function (_level, _msg) {

        switch (_level) {
            case 'debug':
                if (this.getLogLevel() === 'debug') {
                    console.log(_msg);
                }
                break;
            case 'info':
                console.log(_msg);
                break;
            case 'warn':
                console.warn(_msg);
                break;
            case 'error':
                console.error(_msg);
                break;
            default :
                console.error('This debug level is not defined');
        }
    },

    /**
     * Method for exiting the program with a concrete exit code
     * @param _code Exit code
     */
    exit: function (_code) {
        this.log('debug', 'exiting program with code <' + _code + '>');
        process.exit(_code);
    },

    /**
     * Returns the full execution path of the bin command
     * @returns {string} bin command path
     */
    getBinPath: function () {
        return 'node ' + path.join(__dirname, '../src/dockgrant.js') + ' ';
    },

    /**
     * Function for testing if a concrete command is installed on the system
     * @param _command Command to test
     */
    isCommandAvailable: function (_command) {

        if (shell.exec(_command, {silent: true}).code !== 0) {
            this.log('error', 'The command <' + _command + '> is not available');
            this.exit(1);
        } else {
            this.log('debug', 'The command <' + _command + '> is available!');
        }
    },

    setLogLevel: function (_level) {
        level = _level;
    },

    getLogLevel: function () {
        return level;
    }

};

@@ -8,16 +8,35 @@
 rict';%0A%0A
+require('colors');%0A
 var path
@@ -54,16 +54,48 @@
 'path');
+%0Avar shell = require('shelljs');
 %0A%0Avar le
@@ -433,37 +433,44 @@
     console.log(
+(
 _msg)
+.blue)
 ;%0A              
@@ -633,21 +633,30 @@
 le.warn(
+(
 _msg)
+.yellow)
 ;%0A      
@@ -728,21 +728,27 @@
 e.error(
+(
 _msg)
+.red)
 ;%0A      
@@ -816,16 +816,17 @@
 e.error(
+(
 'This de
@@ -851,16 +851,21 @@
 efined')
+.red)
 ;%0A      
@@ -1826,72 +1826,256 @@
     
-setLogLevel: function (_level) %7B%0A        level = _level;%0A    %7D,%0A
+/**%0A     * Sets the log level of the application%0A     * @param _level Level of log%0A     */%0A    setLogLevel: function (_level) %7B%0A        level = _level;%0A    %7D,%0A%0A    /**%0A     * Returns the log level of the application%0A     * @returns %7Bstring%7D%0A     */
 %0A   

Configure logging