New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

custom-log

Package Overview
Dependencies
Maintainers
1
Versions
17
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

custom-log - npm Package Compare versions

Comparing version 0.2.2 to 0.2.3

.npmignore

32

custom-log.js

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

// Generated by CoffeeScript 1.9.1
// Generated by CoffeeScript 1.10.0
(function() {

@@ -20,18 +20,22 @@ "use strict";

customLog = function(init) {
var CUSTOM_LOG, Log, enact, fn, level, log, logInstance, message, prefixMsg;
var CUSTOM_LOG, Log, enact, fn, level, log, logInstance, prefix, prefixMsg;
CUSTOM_LOG = 'custom-log: ';
Log = (function() {
function Log(level1, message1) {
var prop, value;
this.level = level1 != null ? level1 : 'log';
this.message = message1 != null ? message1 : '';
function Log(level, prefix) {
this.assert = bind(this.assert, this);
this.enable = bind(this.enable, this);
this.disable = bind(this.disable, this);
var prop, value;
this.enabled = true;
this.level = level || 'log';
this.prefix = prefix || '';
this.log = (function(_this) {
return function() {
var ref;
var message, ref;
if (_this.enabled) {
return console.log.apply(console, (ref = [_this.message]).concat.apply(ref, arguments));
message = arguments;
if (_this.prefix) {
message = (ref = [_this.prefix]).concat.apply(ref, arguments);
}
return console.log.apply(console, message);
}

@@ -111,15 +115,15 @@ };

if (typeof init === 'object') {
fn = function(level, message) {
fn = function(level, prefix) {
switch (level) {
case 'log':
return logInstance.message = message;
return logInstance.prefix = prefix;
case 'assert':
return customLog.assertMessage = message;
return customLog.assertMessage = prefix;
default:
return log[level] = new Log(level, message).log;
return log[level] = new Log(level, prefix).log;
}
};
for (level in init) {
message = init[level];
fn(level, message);
prefix = init[level];
fn(level, prefix);
}

@@ -126,0 +130,0 @@ }

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

(function(){"use strict";var customLog,intoArray,bind=function(e,t){return function(){return e.apply(t,arguments)}},slice=[].slice;intoArray=function(e){return e.length<2&&("string"==typeof e[0]?e=e.join("").replace(/^\s+|\s+$/g,"").replace(/\s+/g," ").split(" "):"object"==typeof e[0]&&e[0]instanceof Array&&(e=e[0])),e},customLog=function(init){var CUSTOM_LOG,Log,enact,fn,level,log,logInstance,message,prefixMsg;if(CUSTOM_LOG="custom-log: ",Log=function(){function Log(e,t){var n,o;this.level=null!=e?e:"log",this.message=null!=t?t:"",this.assert=bind(this.assert,this),this.enable=bind(this.enable,this),this.disable=bind(this.disable,this),this.enabled=!0,this.log=function(e){return function(){var t;return e.enabled?console.log.apply(console,(t=[e.message]).concat.apply(t,arguments)):void 0}}(this);for(n in this)o=this[n],this.hasOwnProperty(n)&&"log"!==n&&(this.log[n]=o)}return Log.prototype.disable=function(){return this.enabled=!1,console.log(CUSTOM_LOG+"."+this.level+" is disabled")},Log.prototype.enable=function(){return this.enabled=!0,console.log(CUSTOM_LOG+"."+this.level+" is enabled")},Log.prototype.assert=function(predicate,description){return null==description&&(description=""),"string"==typeof predicate&&(description=predicate),description&&(description="("+description+") == "),"string"==typeof predicate&&(predicate=eval(predicate)),predicate=predicate?"TRUE":"FALSE",this.log("\n "+customLog.assertMessage+description+predicate+"\n")},Log}(),"string"==typeof init&&(prefixMsg=init),logInstance=new Log("log",prefixMsg),log=logInstance.log,enact=function(){var e,t,n,o,i,s;for(i=arguments[0],o=2<=arguments.length?slice.call(arguments,1):[],o=intoArray(o),s=[],e=0,t=o.length;t>e;e++)n=o[e],s.push("log"===n?logInstance[i]():null!=log[n]?log[n][i]():void 0);return s},log.enable=function(){return enact.apply(null,["enable"].concat(slice.call(arguments)))},log.disable=function(){return enact.apply(null,["disable"].concat(slice.call(arguments)))},"object"==typeof init){fn=function(e,t){switch(e){case"log":return logInstance.message=t;case"assert":return customLog.assertMessage=t;default:return log[e]=new Log(e,t).log}};for(level in init)message=init[level],fn(level,message)}return log},customLog.assertMessage="Assert: ","undefined"!=typeof define&&null!==define&&"function"==typeof define&&define.amd?define("customLog",[],function(){return customLog}):"undefined"!=typeof module?module.exports=customLog:"undefined"!=typeof window&&(window.customLog=customLog)}).call(this);
(function(){"use strict";var customLog,intoArray,bind=function(e,t){return function(){return e.apply(t,arguments)}},slice=[].slice;intoArray=function(e){return e.length<2&&("string"==typeof e[0]?e=e.join("").replace(/^\s+|\s+$/g,"").replace(/\s+/g," ").split(" "):"object"==typeof e[0]&&e[0]instanceof Array&&(e=e[0])),e},customLog=function(init){var CUSTOM_LOG,Log,enact,fn,level,log,logInstance,prefix,prefixMsg;if(CUSTOM_LOG="custom-log: ",Log=function(){function Log(e,t){this.assert=bind(this.assert,this),this.enable=bind(this.enable,this),this.disable=bind(this.disable,this);var n,i;this.enabled=!0,this.level=e||"log",this.prefix=t||"",this.log=function(e){return function(){var t,n;return e.enabled?(t=arguments,e.prefix&&(t=(n=[e.prefix]).concat.apply(n,arguments)),console.log.apply(console,t)):void 0}}(this);for(n in this)i=this[n],this.hasOwnProperty(n)&&"log"!==n&&(this.log[n]=i)}return Log.prototype.disable=function(){return this.enabled=!1,console.log(CUSTOM_LOG+"."+this.level+" is disabled")},Log.prototype.enable=function(){return this.enabled=!0,console.log(CUSTOM_LOG+"."+this.level+" is enabled")},Log.prototype.assert=function(predicate,description){return null==description&&(description=""),"string"==typeof predicate&&(description=predicate),description&&(description="("+description+") == "),"string"==typeof predicate&&(predicate=eval(predicate)),predicate=predicate?"TRUE":"FALSE",this.log("\n "+customLog.assertMessage+description+predicate+"\n")},Log}(),"string"==typeof init&&(prefixMsg=init),logInstance=new Log("log",prefixMsg),log=logInstance.log,enact=function(){var e,t,n,i,o,s;for(o=arguments[0],i=2<=arguments.length?slice.call(arguments,1):[],i=intoArray(i),s=[],e=0,t=i.length;t>e;e++)n=i[e],s.push("log"===n?logInstance[o]():null!=log[n]?log[n][o]():void 0);return s},log.enable=function(){return enact.apply(null,["enable"].concat(slice.call(arguments)))},log.disable=function(){return enact.apply(null,["disable"].concat(slice.call(arguments)))},"object"==typeof init){fn=function(e,t){switch(e){case"log":return logInstance.prefix=t;case"assert":return customLog.assertMessage=t;default:return log[e]=new Log(e,t).log}};for(level in init)prefix=init[level],fn(level,prefix)}return log},customLog.assertMessage="Assert: ","undefined"!=typeof define&&null!==define&&"function"==typeof define&&define.amd?define("customLog",[],function(){return customLog}):"undefined"!=typeof module?module.exports=customLog:"undefined"!=typeof window&&(window.customLog=customLog)}).call(this);
{
"name": "custom-log",
"version": "0.2.2",
"version": "0.2.3",
"description": "A tiny flexible logger",

@@ -24,2 +24,2 @@ "main": "custom-log.min.js",

"homepage": "https://github.com/phazelift/custom-log"
}
}

@@ -6,9 +6,5 @@ custom-log

For browser, node, amd.
custom-log is targeted at the Browser as a tiny helper that makes available any custom log function you can create yourself, and which can be enabled/disabled individually.
custom-log is targeted at the Browser as a tiny helper that makes available any custom log function you can
create yourself, and which can be enabled/disabled individually.
Although there are plenty full-fledged loggers for use in node, you can use this one instead if you don't
need a zillion features, but rather prefer simplicity.
Although there are plenty full-fledged loggers for use in node, you can use this one instead if you don't need a zillion features but rather prefer simplicity.
___

@@ -19,2 +15,9 @@

First install:
>Browser: `<script src="./custom-log.min.js"></script>`
>Node: `npm install --save custom-log`
<br/>
> `<function> customLog( <string>/<object> init )`

@@ -29,17 +32,14 @@

// customLog is global when load in browser
// but in node:
// customLog is global when loaded in browser, for node use:
var customLog= require( 'custom-log' );
// create a single log function with prefix:
var log= customLog( 'LOG: ' );
// create a single log function without prefix:
var log= customLog();
log( 'hey!' );
// LOG: hey!
// hey!
// or create a log function with multiple custom log functions attached to it:
var log= customLog({
// when omitting log, no prefix for the default log function will be used
log : 'LOG: ',
info : 'INFO: ',

@@ -54,3 +54,3 @@ warning : 'WARNING: ',

log( 'hello' );
// LOG: hello
// hello

@@ -76,24 +76,2 @@ log.info( 'easy!' );

log.enable( ['error', 'listener', 'log'] );
// use build-in assert:
log.assert( 2 > 1 );
// LOG:
// Assert: TRUE
// or with a description
log.assert( 2 > 1, '2 > 1' );
// or wrap in a string to automatically fill the description
log.assert( '2 > 1' );
// LOG:
// Assert: (2 > 1) == TRUE
// change the default assert prefix message:
customLog.assertMessage( '!! ' );
// or add 'assert' to the config object:
var log= customLog({
assert: '!! ',
log : '> ',
// ...
});
```

@@ -106,2 +84,9 @@ ___

0.2.3
- removes leading space for default log without prefix
- log.assert is way too naive and you better use something like the 'assert' npm lib for that. log.assert is now deprecated and will be removed over time.
---
0.2.1

@@ -108,0 +93,0 @@

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