/** * angular-logging * @version v0.0.5 - 2014-05-29 * @link https://github.com/aronvaughan/angular-logging * @author <> * @license MIT License, http://www.opensource.org/licenses/MIT */ "use strict";var AVaughanLogging=AVaughanLogging||{};AVaughanLogging.LogLevel={TRACE:0,DEBUG:1,INFO:2,WARN:3,ERROR:4,textValues:["TRACE","DEBUG","INFO","WARN","ERROR"],getText:function(a){return this.textValues[a]}},AVaughanLogging.DefaultLogConfig={loglevel:AVaughanLogging.LogLevel.INFO,category:{exampleCategory:AVaughanLogging.LogLevel.ERROR}},AVaughanLogging.Logger=function(a,b,c){this.name="AVaughanLogging.Logger",this.$log=a,this.category=c;var d=AVaughanLogging.LogLevel;this.debug=function(b,c){this.getLevel()<=d.DEBUG&&a.debug("["+this.category+"] - DEBUG: "+b,c)},this.info=function(b,c){this.getLevel()<=d.INFO&&a.info("["+this.category+"] - INFO: "+b,c)},this.warn=function(b,c){this.getLevel()<=d.WARN&&a.warn("["+this.category+"] - WARN: "+b,c)},this.error=function(b,c){this.getLevel()<=d.ERROR&&a.error("["+this.category+"] - ERROR "+b,c)},this.getLog=function(){return this.$log},this.getLevel=function(){return b.getLogLevel(this.category)},this.getCategory=function(){return this.category}},AVaughanLogging.Log=function(a){this.name="AVaughanLogging.Log",this.config=AVaughanLogging.DefaultLogConfig;var b=!1;this.$log=a,this.setConfig=function(c){this.config=c,b?a?a.warn("avLog setConfig called multiple times",c):console.log("WARN: avLog setConfig called multiple times, $log was null",c):(b=!0,this.configToConsole())},this.getConfig=function(){return this.config},this.getLogLevel=function(a){var b=this.getConfig().loglevel;return this.getConfig().category[a]&&(b=this.getConfig().category[a]),b},this.getLogger=function(a){var b=new AVaughanLogging.Logger(this.$log,this,a);return b},this.configToConsole=function(){var a=this.getConfig();console.log("-------- Logging Config Start >> --------------"),console.log("Default Level: "+AVaughanLogging.LogLevel.getText(a.loglevel));for(var b in a.category)console.log("CATEGORY: "+b+" VALUE: "+AVaughanLogging.LogLevel.getText(a.category[b]));console.log("raw object",this.getConfig()),console.log("-------- << Logging Config End ----------------")},this.getLog=function(){return this.$log}},angular.module("avaughan.logging",[]).constant("avLevel",AVaughanLogging.LogLevel).factory("avLog",["$log",function(a){return console.log("avLogging instantiated",a),void 0===AVaughanLogging.logInstance?AVaughanLogging.logInstance=new AVaughanLogging.Log(a):AVaughanLogging.logInstance.$log=a,AVaughanLogging.logInstance}]),AVaughanLogging.get=function(a,b){return a.$get[1]().setConfig(b)};