'use strict';


angular.module('qusion.common.logger', [])
    .factory('Logger', [
        function() {

            var KEYS = {
                DISABLE: 'disable',
                ERROR: 'error',
                WARN: 'warn',
                INFO: 'info',
                DEBUG: 'debug'
            };

            var debug = function(message) {
                log(message, KEYS.DEBUG);
            };

            var error = function(message) {
                log(message, KEYS.ERROR);
            };

            var warn = function(message) {
                log(message, KEYS.WARN);
            };

            var info = function(message) {
                log(message, KEYS.INFO);
            };

            var disable = function (message) {
                log(message, KEYS.DISABLE);
            };

            var log = function(message, level) {
                if (window.console) {
                    if (!level || level === KEYS.INFO) {
                        window.console.log(message);
                    } else {
                        if (window.console[level]) {
                            window.console[level](message);
                        } else {
                            window.console.log('<' + level + '> ' + message);
                        }
                    }
                }
            };

            return {
                debug: debug,
                error: error,
                warn: warn,
                info: info,
                disable: disable
            };
        }
    ]);