Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

angular-simple-logger

Package Overview
Dependencies
Maintainers
1
Versions
12
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

angular-simple-logger - npm Package Compare versions

Comparing version 0.0.3 to 0.0.4

2

bower.json
{
"name": "angular-simple-logger",
"version": "0.0.3",
"version": "0.0.4",
"description": "Basic logger with level logging which can also be independent.",

@@ -5,0 +5,0 @@ "main": "./dist/angular-simple-logger.js",

@@ -26,3 +26,3 @@ {

"no_throwing_strings": {
"level": "warn"
"level": "ignore"
},

@@ -29,0 +29,0 @@ "no_trailing_semicolons": {

/**
* angular-simple-logger
*
* @version: 0.0.3
* @version: 0.0.4
* @author: Nicholas McCready
* @date: Tue Sep 22 2015 14:43:31 GMT-0400 (EDT)
* @date: Tue Sep 22 2015 17:09:12 GMT-0400 (EDT)
* @license: MIT
*/angular.module('nemLogging', []).provider('nemSimpleLogger', function() {
this.$get = [
'$log', function($log) {
var LEVELS, Logger, _fns, log, maybeExecLevel;
_fns = ['log', 'info', 'debug', 'warn', 'error'];
LEVELS = {
log: 1,
info: 2,
debug: 3,
warn: 4,
error: 5
};
maybeExecLevel = function(level, current, fn) {
if (level >= current) {
return fn();
}
};
log = function(logLevelFnName, msg) {
if ($log != null) {
return $log[logLevelFnName](msg);
} else {
return console[logLevelFnName](msg);
}
};
Logger = (function() {
function Logger() {
var logFns;
this.doLog = true;
logFns = {};
_fns.forEach((function(_this) {
return function(level) {
return logFns[level] = function(msg) {
if (_this.doLog) {
return maybeExecLevel(LEVELS[level], _this.currentLevel, function() {
return log(level, msg);
});
}
};
};
})(this));
this.LEVELS = LEVELS;
this.currentLevel = LEVELS.error;
_fns.forEach((function(_this) {
return function(fnName) {
return _this[fnName] = logFns[fnName];
};
})(this));
}
*/var bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; };
Logger.prototype.spawn = function() {
return new Logger();
angular.module('nemLogging', []).provider('nemSimpleLogger', function() {
var LEVELS, Logger, _fns, maybeExecLevel;
_fns = ['log', 'info', 'debug', 'warn', 'error'];
LEVELS = {
log: 1,
info: 2,
debug: 3,
warn: 4,
error: 5
};
maybeExecLevel = function(level, current, fn) {
if (level >= current) {
return fn();
}
};
Logger = (function() {
function Logger($log1) {
var logFns;
this.$log = $log1;
this.spawn = bind(this.spawn, this);
if (!this.$log) {
throw 'internalLogger undefined';
}
this.doLog = true;
logFns = {};
_fns.forEach((function(_this) {
return function(level) {
return logFns[level] = function(msg) {
if (_this.doLog) {
return maybeExecLevel(LEVELS[level], _this.currentLevel, function() {
return _this.$log[level](msg);
});
}
};
};
Logger.prototype.setLog = function(someLogger) {
return $log = someLogger;
})(this));
this.LEVELS = LEVELS;
this.currentLevel = LEVELS.error;
_fns.forEach((function(_this) {
return function(fnName) {
return _this[fnName] = logFns[fnName];
};
})(this));
}
return Logger;
Logger.prototype.spawn = function(newInternalLogger) {
return new Logger(newInternalLogger || this.$log);
};
})();
return new Logger();
return Logger;
})();
this.decorator = [
'$log', function($delegate) {
var log;
log = new Logger($delegate);
log.currentLevel = LEVELS.log;
return log;
}
];
this.$get = [
'$log', function($log) {
return new Logger($log);
}
];
return this;
});

@@ -1,1 +0,1 @@

angular.module("nemLogging",[]).provider("nemSimpleLogger",function(){return this.$get=["$log",function(n){var r,t,o,e,u;return o=["log","info","debug","warn","error"],r={log:1,info:2,debug:3,warn:4,error:5},u=function(n,r,t){return n>=r?t():void 0},e=function(r,t){return null!=n?n[r](t):console[r](t)},new(t=function(){function t(){var n;this.doLog=!0,n={},o.forEach(function(t){return function(o){return n[o]=function(n){return t.doLog?u(r[o],t.currentLevel,function(){return e(o,n)}):void 0}}}(this)),this.LEVELS=r,this.currentLevel=r.error,o.forEach(function(r){return function(t){return r[t]=n[t]}}(this))}return t.prototype.spawn=function(){return new t},t.prototype.setLog=function(r){return n=r},t}())}],this});
var bind=function(n,r){return function(){return n.apply(r,arguments)}};angular.module("nemLogging",[]).provider("nemSimpleLogger",function(){var n,r,t,o;return t=["log","info","debug","warn","error"],n={log:1,info:2,debug:3,warn:4,error:5},o=function(n,r,t){return n>=r?t():void 0},r=function(){function r(r){var e;if(this.$log=r,this.spawn=bind(this.spawn,this),!this.$log)throw"internalLogger undefined";this.doLog=!0,e={},t.forEach(function(r){return function(t){return e[t]=function(e){return r.doLog?o(n[t],r.currentLevel,function(){return r.$log[t](e)}):void 0}}}(this)),this.LEVELS=n,this.currentLevel=n.error,t.forEach(function(n){return function(r){return n[r]=e[r]}}(this))}return r.prototype.spawn=function(n){return new r(n||this.$log)},r}(),this.decorator=["$log",function(t){var o;return o=new r(t),o.currentLevel=n.log,o}],this.$get=["$log",function(n){return new r(n)}],this});
/**
* angular-simple-logger
*
* @version: 0.0.3
* @version: 0.0.4
* @author: Nicholas McCready
* @date: Tue Sep 22 2015 14:43:31 GMT-0400 (EDT)
* @date: Tue Sep 22 2015 17:09:12 GMT-0400 (EDT)
* @license: MIT
*/angular.module('nemLogging', []).provider('nemSimpleLogger', function() {
this.$get = [
'$log', function($log) {
var LEVELS, Logger, _fns, log, maybeExecLevel;
_fns = ['log', 'info', 'debug', 'warn', 'error'];
LEVELS = {
log: 1,
info: 2,
debug: 3,
warn: 4,
error: 5
};
maybeExecLevel = function(level, current, fn) {
if (level >= current) {
return fn();
}
};
log = function(logLevelFnName, msg) {
if ($log != null) {
return $log[logLevelFnName](msg);
} else {
return console[logLevelFnName](msg);
}
};
Logger = (function() {
function Logger() {
var logFns;
this.doLog = true;
logFns = {};
_fns.forEach((function(_this) {
return function(level) {
return logFns[level] = function(msg) {
if (_this.doLog) {
return maybeExecLevel(LEVELS[level], _this.currentLevel, function() {
return log(level, msg);
});
}
};
};
})(this));
this.LEVELS = LEVELS;
this.currentLevel = LEVELS.error;
_fns.forEach((function(_this) {
return function(fnName) {
return _this[fnName] = logFns[fnName];
};
})(this));
}
*/var bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; };
Logger.prototype.spawn = function() {
return new Logger();
angular.module('nemLogging', []).provider('nemSimpleLogger', function() {
var LEVELS, Logger, _fns, maybeExecLevel;
_fns = ['log', 'info', 'debug', 'warn', 'error'];
LEVELS = {
log: 1,
info: 2,
debug: 3,
warn: 4,
error: 5
};
maybeExecLevel = function(level, current, fn) {
if (level >= current) {
return fn();
}
};
Logger = (function() {
function Logger($log1) {
var logFns;
this.$log = $log1;
this.spawn = bind(this.spawn, this);
if (!this.$log) {
throw 'internalLogger undefined';
}
this.doLog = true;
logFns = {};
_fns.forEach((function(_this) {
return function(level) {
return logFns[level] = function(msg) {
if (_this.doLog) {
return maybeExecLevel(LEVELS[level], _this.currentLevel, function() {
return _this.$log[level](msg);
});
}
};
};
Logger.prototype.setLog = function(someLogger) {
return $log = someLogger;
})(this));
this.LEVELS = LEVELS;
this.currentLevel = LEVELS.error;
_fns.forEach((function(_this) {
return function(fnName) {
return _this[fnName] = logFns[fnName];
};
})(this));
}
return Logger;
Logger.prototype.spawn = function(newInternalLogger) {
return new Logger(newInternalLogger || this.$log);
};
})();
return new Logger();
return Logger;
})();
this.decorator = [
'$log', function($delegate) {
var log;
log = new Logger($delegate);
log.currentLevel = LEVELS.log;
return log;
}
];
this.$get = [
'$log', function($log) {
return new Logger($log);
}
];
return this;
});
{
"name": "angular-simple-logger",
"version": "0.0.3",
"version": "0.0.4",
"description": "Basic logger with level logging which can also be independent.",

@@ -5,0 +5,0 @@ "main": "./dist/angular-simple-logger.js",

@@ -69,2 +69,26 @@ angular-simple-logger (nemLogging.nemSimpleLogger)

### Override all of $log (optional decorator)
Optionally (default is off) decorate $log to utilize log levels globally within the app.
Note this logger's currentLevel is info!
```js
angular.module('someApp', ['nemLogging']))
.config(function($provide, nemSimpleLoggerProvider) {
return $provide.decorator.apply(null, nemSimpleLoggerProvider.decorator);
})
.config(function($provide, nemSimpleLoggerProvider) {
var logger = $provide.decorator.apply(null, nemSimpleLoggerProvider.decorator);
//override level at config
logger.currentLevel = logger.LEVELS.error;
return logger;
})
.run(function($log){
//at run time
//override the default log level globally
$log.currentLevel = $log.LEVELS.error;
});
```
### API

@@ -71,0 +95,0 @@ Underneath it all it is still calling `$log` so calling the logger for logging itself is the same.

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc