├── AUTHORS ├── .gitignore ├── tests ├── README.md ├── simulator.js ├── test_console.js ├── test_sink_alert.js ├── test_sink_debugger.js ├── test_sink_console.js └── test_sink_short.js ├── dist ├── test.js ├── sinks │ ├── debugger.js │ ├── alert.js │ ├── short.js │ ├── exception.js │ ├── raw.js │ └── console.js ├── console.js ├── assert.js └── main.js ├── .editorconfig ├── test.js ├── sinks ├── debugger.js ├── alert.js ├── short.js ├── exception.js ├── raw.js └── console.js ├── bower.json ├── package.json ├── console.js ├── README.md ├── assert.js ├── main.js └── LICENSE /AUTHORS: -------------------------------------------------------------------------------- 1 | Eugene Lazutkin (http://lazutkin.com/) 2 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | node_modules/* 2 | *.iml 3 | .idea 4 | *.sublime-* 5 | report/* 6 | coverage/* 7 | -------------------------------------------------------------------------------- /tests/README.md: -------------------------------------------------------------------------------- 1 | This folder contains manual node.js-based tests. All automated tests 2 | are moved to heya-unit to avoid circular references. 3 | -------------------------------------------------------------------------------- /dist/test.js: -------------------------------------------------------------------------------- 1 | (function(_,f){window.heya.ice.test=f(window.heya.ice.assert);}) 2 | (["./assert"], function(ice){ 3 | "use strict"; 4 | 5 | ice._addCond(ice.Ice, 200, "test"); 6 | 7 | return ice; 8 | }); 9 | -------------------------------------------------------------------------------- /.editorconfig: -------------------------------------------------------------------------------- 1 | root = true 2 | 3 | [*] 4 | charset = utf-8 5 | end_of_line = lf 6 | insert_final_newline = true 7 | trim_trailing_whitespace = true 8 | indent_style = tab 9 | indent_size = 4 10 | 11 | [*.{json,yml,md}] 12 | indent_style = space 13 | indent_size = 2 14 | -------------------------------------------------------------------------------- /test.js: -------------------------------------------------------------------------------- 1 | /* UMD.define */ (typeof define=="function"&&define||function(d,f,m){m={module:module,require:require};module.exports=f.apply(null,d.map(function(n){return m[n]||require(n)}))}) 2 | (["./assert"], function(ice){ 3 | "use strict"; 4 | 5 | ice._addCond(ice.Ice, 200, "test"); 6 | 7 | return ice; 8 | }); 9 | -------------------------------------------------------------------------------- /dist/sinks/debugger.js: -------------------------------------------------------------------------------- 1 | (function(_,f,g){g=window;g=g.heya||(g.heya={});g=g.ice||(g.ice={});g=g.sinks||(g.sinks={});g.debugger=f();}) 2 | ([], function(){ 3 | "use strict"; 4 | 5 | return function debuggerSink(ice, meta, text, condition, custom){ 6 | var flag = false; 7 | debugger; 8 | // set flag to true to stop logging and return back to the logging site 9 | return flag; 10 | }; 11 | }); 12 | -------------------------------------------------------------------------------- /tests/simulator.js: -------------------------------------------------------------------------------- 1 | /* UMD.define */ (typeof define=="function"&&define||function(d,f,m){m={module:module,require:require};module.exports=f.apply(null,d.map(function(n){return m[n]||require(n)}))}) 2 | (["module", "../main"], function(module, ice){ 3 | "use strict"; 4 | 5 | var ice = ice.specialize(module); 6 | 7 | function simulator(methodName, args){ 8 | eval(ice[methodName].apply(ice, args)); 9 | } 10 | 11 | return simulator; 12 | }); -------------------------------------------------------------------------------- /sinks/debugger.js: -------------------------------------------------------------------------------- 1 | /* UMD.define */ (typeof define=="function"&&define||function(d,f,m){m={module:module,require:require};module.exports=f.apply(null,d.map(function(n){return m[n]||require(n)}))}) 2 | ([], function(){ 3 | "use strict"; 4 | 5 | return function debuggerSink(ice, meta, text, condition, custom){ 6 | var flag = false; 7 | debugger; 8 | // set flag to true to stop logging and return back to the logging site 9 | return flag; 10 | }; 11 | }); 12 | -------------------------------------------------------------------------------- /dist/sinks/alert.js: -------------------------------------------------------------------------------- 1 | (function(_,f,g){g=window;g=g.heya||(g.heya={});g=g.ice||(g.ice={});g=g.sinks||(g.sinks={});g.alert=f();}) 2 | ([], function(){ 3 | "use strict"; 4 | 5 | return function alertSink(ice, meta, text, condition, custom){ 6 | alert(meta.name.toUpperCase() + ": " + (text || condition || "-") + 7 | (meta.filename ? " in " + meta.filename : "") + 8 | (meta.filename && meta.id && meta.filename != meta.id ? " as " + meta.id : "")); 9 | }; 10 | }); 11 | -------------------------------------------------------------------------------- /dist/sinks/short.js: -------------------------------------------------------------------------------- 1 | (function(_,f,g){g=window;g=g.heya||(g.heya={});g=g.ice||(g.ice={});g=g.sinks||(g.sinks={});g.short=f();}) 2 | ([], function(){ 3 | "use strict"; 4 | 5 | return function shortSink(ice, meta, text, condition, custom){ 6 | console.log(meta.name.toUpperCase() + ": " + (text || condition || "-") + 7 | (meta.filename ? " in " + meta.filename : "") + 8 | (meta.filename && meta.id && meta.filename != meta.id ? " as " + meta.id : "")); 9 | }; 10 | }); 11 | -------------------------------------------------------------------------------- /dist/sinks/exception.js: -------------------------------------------------------------------------------- 1 | (function(_,f,g){g=window;g=g.heya||(g.heya={});g=g.ice||(g.ice={});g=g.sinks||(g.sinks={});g.exception=f();}) 2 | ([], function(){ 3 | "use strict"; 4 | 5 | return function exceptionSink(ice, meta, text, condition, custom){ 6 | var error = new Error(meta.name.toUpperCase() + ": " + (text || condition || "anonymous")); 7 | error.ice = ice; 8 | error.meta = meta; 9 | error.text = text; 10 | error.condition = condition; 11 | error.custom = custom; 12 | throw error; 13 | }; 14 | }); 15 | -------------------------------------------------------------------------------- /sinks/alert.js: -------------------------------------------------------------------------------- 1 | /* UMD.define */ (typeof define=="function"&&define||function(d,f,m){m={module:module,require:require};module.exports=f.apply(null,d.map(function(n){return m[n]||require(n)}))}) 2 | ([], function(){ 3 | "use strict"; 4 | 5 | return function alertSink(ice, meta, text, condition, custom){ 6 | alert(meta.name.toUpperCase() + ": " + (text || condition || "-") + 7 | (meta.filename ? " in " + meta.filename : "") + 8 | (meta.filename && meta.id && meta.filename != meta.id ? " as " + meta.id : "")); 9 | }; 10 | }); 11 | -------------------------------------------------------------------------------- /sinks/short.js: -------------------------------------------------------------------------------- 1 | /* UMD.define */ (typeof define=="function"&&define||function(d,f,m){m={module:module,require:require};module.exports=f.apply(null,d.map(function(n){return m[n]||require(n)}))}) 2 | ([], function(){ 3 | "use strict"; 4 | 5 | return function shortSink(ice, meta, text, condition, custom){ 6 | console.log(meta.name.toUpperCase() + ": " + (text || condition || "-") + 7 | (meta.filename ? " in " + meta.filename : "") + 8 | (meta.filename && meta.id && meta.filename != meta.id ? " as " + meta.id : "")); 9 | }; 10 | }); 11 | -------------------------------------------------------------------------------- /sinks/exception.js: -------------------------------------------------------------------------------- 1 | /* UMD.define */ (typeof define=="function"&&define||function(d,f,m){m={module:module,require:require};module.exports=f.apply(null,d.map(function(n){return m[n]||require(n)}))}) 2 | ([], function(){ 3 | "use strict"; 4 | 5 | return function exceptionSink(ice, meta, text, condition, custom){ 6 | var error = new Error(meta.name.toUpperCase() + ": " + (text || condition || "anonymous")); 7 | error.ice = ice; 8 | error.meta = meta; 9 | error.text = text; 10 | error.condition = condition; 11 | error.custom = custom; 12 | throw error; 13 | }; 14 | }); 15 | -------------------------------------------------------------------------------- /tests/test_console.js: -------------------------------------------------------------------------------- 1 | /* UMD.define */ (typeof define=="function"&&define||function(d,f,m){m={module:module,require:require};module.exports=f.apply(null,d.map(function(n){return m[n]||require(n)}))}) 2 | (["module", "../test", "../console"], function(module, ice, console){ 3 | "use strict"; 4 | 5 | ice = ice.specialize(module); 6 | console = console.specialize(ice); 7 | 8 | // local tests 9 | 10 | console.info("Info"); 11 | console.warn("Warn"); 12 | try{ 13 | console.error("Error"); 14 | }catch(e){ 15 | console.info(e); 16 | } 17 | 18 | console.log("Formatting: %d%, %s, %j", 99, "Ouch!", {x: 1}); 19 | }); 20 | -------------------------------------------------------------------------------- /bower.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "heya-ice", 3 | "description": "ICE: logging, debugging, and assert facility.", 4 | "main": "main.js", 5 | "authors": [ 6 | "Eugene Lazutkin (http://lazutkin.com/)" 7 | ], 8 | "license": "BSD-3-Clause", 9 | "keywords": [ 10 | "logging", 11 | "debugging", 12 | "assertion", 13 | "debug", 14 | "assert", 15 | "log" 16 | ], 17 | "homepage": "https://github.com/heya/ice", 18 | "moduleType": [ 19 | "amd", 20 | "globals", 21 | "node" 22 | ], 23 | "ignore": [ 24 | "**/.*", 25 | "node_modules", 26 | "bower_components", 27 | "test", 28 | "tests" 29 | ] 30 | } 31 | -------------------------------------------------------------------------------- /dist/sinks/raw.js: -------------------------------------------------------------------------------- 1 | (function(_,f,g){g=window;g=g.heya||(g.heya={});g=g.ice||(g.ice={});g=g.sinks||(g.sinks={});g.raw=f();}) 2 | ([], function(){ 3 | "use strict"; 4 | 5 | return function rawSink(limit){ 6 | var queue = []; 7 | return { 8 | limit: limit, 9 | getQueue: function(){ 10 | return queue; 11 | }, 12 | clearQueue: function(){ 13 | queue.length && queue.splice(0, queue.length); 14 | }, 15 | log: function rawTransport(ice, meta, text, condition, custom){ 16 | while(queue.length >= limit){ 17 | queue.shift(); 18 | } 19 | queue.push({ice: ice, meta: meta, text: text, condition: condition, custom: custom}); 20 | } 21 | }; 22 | }; 23 | }); 24 | -------------------------------------------------------------------------------- /sinks/raw.js: -------------------------------------------------------------------------------- 1 | /* UMD.define */ (typeof define=="function"&&define||function(d,f,m){m={module:module,require:require};module.exports=f.apply(null,d.map(function(n){return m[n]||require(n)}))}) 2 | ([], function(){ 3 | "use strict"; 4 | 5 | return function rawSink(limit){ 6 | var queue = []; 7 | return { 8 | limit: limit, 9 | getQueue: function(){ 10 | return queue; 11 | }, 12 | clearQueue: function(){ 13 | queue.length && queue.splice(0, queue.length); 14 | }, 15 | log: function rawTransport(ice, meta, text, condition, custom){ 16 | while(queue.length >= limit){ 17 | queue.shift(); 18 | } 19 | queue.push({ice: ice, meta: meta, text: text, condition: condition, custom: custom}); 20 | } 21 | }; 22 | }; 23 | }); 24 | -------------------------------------------------------------------------------- /dist/sinks/console.js: -------------------------------------------------------------------------------- 1 | (function(_,f,g){g=window;g=g.heya||(g.heya={});g=g.ice||(g.ice={});g=g.sinks||(g.sinks={});g.console=f();}) 2 | ([], function(){ 3 | "use strict"; 4 | 5 | return function consoleSink(ice, meta, text, condition, custom){ 6 | console.log(meta.name + ": " + meta.level + " on " + 7 | meta.time.toUTCString() + " in " + meta.filename + 8 | (meta.filename !== meta.id ? " as " + meta.id : "")); 9 | if(text){ 10 | console.log(meta.name + ": text - " + text); 11 | } 12 | if(condition){ 13 | console.log(meta.name + ": cond - " + condition); 14 | } 15 | if(custom){ 16 | console.log(meta.name + ": custom - ", custom); 17 | } 18 | if(meta.stack){ 19 | console.log(meta.name + ": stack"); 20 | console.log(meta.stack); 21 | console.log(meta.name + ": end of stack"); 22 | } 23 | }; 24 | }); 25 | -------------------------------------------------------------------------------- /sinks/console.js: -------------------------------------------------------------------------------- 1 | /* UMD.define */ (typeof define=="function"&&define||function(d,f,m){m={module:module,require:require};module.exports=f.apply(null,d.map(function(n){return m[n]||require(n)}))}) 2 | ([], function(){ 3 | "use strict"; 4 | 5 | return function consoleSink(ice, meta, text, condition, custom){ 6 | console.log(meta.name + ": " + meta.level + " on " + 7 | meta.time.toUTCString() + " in " + meta.filename + 8 | (meta.filename !== meta.id ? " as " + meta.id : "")); 9 | if(text){ 10 | console.log(meta.name + ": text - " + text); 11 | } 12 | if(condition){ 13 | console.log(meta.name + ": cond - " + condition); 14 | } 15 | if(custom){ 16 | console.log(meta.name + ": custom - ", custom); 17 | } 18 | if(meta.stack){ 19 | console.log(meta.name + ": stack"); 20 | console.log(meta.stack); 21 | console.log(meta.name + ": end of stack"); 22 | } 23 | }; 24 | }); 25 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "heya-ice", 3 | "version": "0.1.11", 4 | "description": "ICE: logging, debugging, and assert facility.", 5 | "main": "main.js", 6 | "directories": { 7 | "test": "tests" 8 | }, 9 | "dependencies": {}, 10 | "devDependencies": { 11 | "heya-globalize": "^1.0.2" 12 | }, 13 | "scripts": { 14 | "test": "node tests/test_sink_short.js", 15 | "dist": "node node_modules/heya-globalize/index.js" 16 | }, 17 | "repository": { 18 | "type": "git", 19 | "url": "git://github.com/heya/ice.git" 20 | }, 21 | "keywords": [ 22 | "logging", 23 | "debugging", 24 | "assertion", 25 | "debug", 26 | "assert", 27 | "log" 28 | ], 29 | "author": "Eugene Lazutkin (http://lazutkin.com/)", 30 | "license": "BSD-3-Clause", 31 | "volo": { 32 | "type": "directory" 33 | }, 34 | "browserGlobals": { 35 | "!root": "heya.ice" 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /tests/test_sink_alert.js: -------------------------------------------------------------------------------- 1 | /* UMD.define */ (typeof define=="function"&&define||function(d,f,m){m={module:module,require:require};module.exports=f.apply(null,d.map(function(n){return m[n]||require(n)}))}) 2 | (["module", "../test", "../sinks/alert"], function(module, ice, alertSink){ 3 | "use strict"; 4 | 5 | var ice = ice.specialize(module); 6 | ice.setNamedTransports("default", [{log: alertSink}]); 7 | 8 | // local tests 9 | 10 | ice.info("Info"); 11 | ice.warn("Warn"); 12 | try{ 13 | ice.error("Error"); 14 | }catch(e){ 15 | ice.info(e); 16 | } 17 | 18 | ice.test(1 < 2, "Test #1"); 19 | eval(ice.TEST("1 < 2")); 20 | ice.test(3 < 2, "Test #2"); 21 | eval(ice.TEST("3 < 2")); 22 | 23 | ice.assert(1 < 2, "Test #1"); 24 | eval(ice.ASSERT("1 < 2")); 25 | try{ 26 | ice.assert(3 < 2, "Test #2"); 27 | }catch(e){ 28 | ice.info(e); 29 | } 30 | try{ 31 | eval(ice.ASSERT("3 < 2")); 32 | }catch(e){ 33 | ice.info(e); 34 | } 35 | }); 36 | -------------------------------------------------------------------------------- /tests/test_sink_debugger.js: -------------------------------------------------------------------------------- 1 | /* UMD.define */ (typeof define=="function"&&define||function(d,f,m){m={module:module,require:require};module.exports=f.apply(null,d.map(function(n){return m[n]||require(n)}))}) 2 | (["module", "../test", "../sinks/debugger"], function(module, ice, debuggerSink){ 3 | "use strict"; 4 | 5 | var ice = ice.specialize(module); 6 | ice.setNamedTransports("default", [{log: debuggerSink}]); 7 | 8 | // local tests 9 | 10 | ice.info("Info"); 11 | ice.warn("Warn"); 12 | try{ 13 | ice.error("Error"); 14 | }catch(e){ 15 | ice.info(e); 16 | } 17 | 18 | ice.test(1 < 2, "Test #1"); 19 | eval(ice.TEST("1 < 2")); 20 | ice.test(3 < 2, "Test #2"); 21 | eval(ice.TEST("3 < 2")); 22 | 23 | ice.assert(1 < 2, "Test #1"); 24 | eval(ice.ASSERT("1 < 2")); 25 | try{ 26 | ice.assert(3 < 2, "Test #2"); 27 | }catch(e){ 28 | ice.info(e); 29 | } 30 | try{ 31 | eval(ice.ASSERT("3 < 2")); 32 | }catch(e){ 33 | ice.info(e); 34 | } 35 | }); 36 | -------------------------------------------------------------------------------- /tests/test_sink_console.js: -------------------------------------------------------------------------------- 1 | /* UMD.define */ (typeof define=="function"&&define||function(d,f,m){m={module:module,require:require};module.exports=f.apply(null,d.map(function(n){return m[n]||require(n)}))}) 2 | (["module", "../test", "../sinks/console"], function(module, ice, consoleSink){ 3 | "use strict"; 4 | 5 | var ice = ice.specialize(module); 6 | ice.setNamedTransports("default", [{log: consoleSink}]); 7 | 8 | // local tests 9 | 10 | ice.info("Info"); 11 | ice.warn("Warn"); 12 | try{ 13 | ice.error("Error"); 14 | }catch(e){ 15 | ice.info(e); 16 | } 17 | 18 | ice.test(1 < 2, "Test #1"); 19 | eval(ice.TEST("1 < 2")); 20 | ice.test(3 < 2, "Test #2"); 21 | eval(ice.TEST("3 < 2")); 22 | 23 | ice.assert(1 < 2, "Test #1"); 24 | eval(ice.ASSERT("1 < 2")); 25 | try{ 26 | ice.assert(3 < 2, "Test #2"); 27 | }catch(e){ 28 | ice.info(e); 29 | } 30 | try{ 31 | eval(ice.ASSERT("3 < 2")); 32 | }catch(e){ 33 | ice.info(e); 34 | } 35 | 36 | var a = 2, b = {x: 1}; 37 | eval(ice.TEST("a < b.x")); 38 | }); 39 | -------------------------------------------------------------------------------- /dist/console.js: -------------------------------------------------------------------------------- 1 | (function(_,f){window.heya.ice.console=f(window.heya.ice.main);}) 2 | (["./main"], function(ice){ 3 | "use strict"; 4 | 5 | function format(args){ 6 | var result = "", msg = args[0], i = 0; 7 | if(typeof msg == "string"){ 8 | result = msg.replace(/%[difsj]/g, function(pattern){ 9 | if(pattern == "%s"){ 10 | return "" + args[++i]; 11 | } 12 | if(pattern == "%j"){ 13 | return JSON.stringify(args[++i]); 14 | } 15 | return "" + (+args[++i]); 16 | }); 17 | } 18 | var rest = []; 19 | for(++i; i < args.length; ++i){ 20 | rest.push("" + args[i]); 21 | } 22 | if(!rest.length){ 23 | return result; 24 | } 25 | if(result){ 26 | return result + " " + rest.join(" "); 27 | } 28 | return rest.join(" "); 29 | } 30 | 31 | function log(name){ 32 | return function(){ 33 | var args = Array.prototype.slice.call(arguments, 0); 34 | this.ice[name](format(args), args); 35 | }; 36 | } 37 | 38 | function Console(specialIce){ 39 | this.ice = specialIce || ice; 40 | } 41 | 42 | var cp = Console.prototype = { 43 | log: log("info"), 44 | info: log("info"), 45 | warn: log("warn"), 46 | error: log("error"), 47 | specialize: function(specialIce){ 48 | return new Console(specialIce); 49 | } 50 | }; 51 | 52 | if(typeof console == "object"){ 53 | for(var name in console){ 54 | if(!cp.hasOwnProperty(name)){ 55 | cp[name] = console[name]; 56 | } 57 | } 58 | } 59 | 60 | return new Console(); 61 | }); 62 | -------------------------------------------------------------------------------- /console.js: -------------------------------------------------------------------------------- 1 | /* UMD.define */ (typeof define=="function"&&define||function(d,f,m){m={module:module,require:require};module.exports=f.apply(null,d.map(function(n){return m[n]||require(n)}))}) 2 | (["./main"], function(ice){ 3 | "use strict"; 4 | 5 | function format(args){ 6 | var result = "", msg = args[0], i = 0; 7 | if(typeof msg == "string"){ 8 | result = msg.replace(/%[difsj]/g, function(pattern){ 9 | if(pattern == "%s"){ 10 | return "" + args[++i]; 11 | } 12 | if(pattern == "%j"){ 13 | return JSON.stringify(args[++i]); 14 | } 15 | return "" + (+args[++i]); 16 | }); 17 | } 18 | var rest = []; 19 | for(++i; i < args.length; ++i){ 20 | rest.push("" + args[i]); 21 | } 22 | if(!rest.length){ 23 | return result; 24 | } 25 | if(result){ 26 | return result + " " + rest.join(" "); 27 | } 28 | return rest.join(" "); 29 | } 30 | 31 | function log(name){ 32 | return function(){ 33 | var args = Array.prototype.slice.call(arguments, 0); 34 | this.ice[name](format(args), args); 35 | }; 36 | } 37 | 38 | function Console(specialIce){ 39 | this.ice = specialIce || ice; 40 | } 41 | 42 | var cp = Console.prototype = { 43 | log: log("info"), 44 | info: log("info"), 45 | warn: log("warn"), 46 | error: log("error"), 47 | specialize: function(specialIce){ 48 | return new Console(specialIce); 49 | } 50 | }; 51 | 52 | if(typeof console == "object"){ 53 | for(var name in console){ 54 | if(!cp.hasOwnProperty(name)){ 55 | cp[name] = console[name]; 56 | } 57 | } 58 | } 59 | 60 | return new Console(); 61 | }); 62 | -------------------------------------------------------------------------------- /tests/test_sink_short.js: -------------------------------------------------------------------------------- 1 | /* UMD.define */ (typeof define=="function"&&define||function(d,f,m){m={module:module,require:require};module.exports=f.apply(null,d.map(function(n){return m[n]||require(n)}))}) 2 | (["module", "../test", "./simulator", "../sinks/short"], 3 | function(module, ice, simulator, shortSink){ 4 | "use strict"; 5 | 6 | var ice = ice.specialize(module); 7 | ice.setNamedTransports("default", [{log: shortSink}]); 8 | 9 | // local tests 10 | 11 | ice.info("Info"); 12 | ice.warn("Warn"); 13 | try{ 14 | ice.error("Error"); 15 | }catch(e){ 16 | ice.info(e); 17 | } 18 | 19 | ice.test(1 < 2, "Test #1"); 20 | eval(ice.TEST("1 < 2")); 21 | ice.test(3 < 2, "Test #2"); 22 | eval(ice.TEST("3 < 2")); 23 | 24 | ice.assert(1 < 2, "Test #1"); 25 | eval(ice.ASSERT("1 < 2")); 26 | try{ 27 | ice.assert(3 < 2, "Test #2"); 28 | }catch(e){ 29 | ice.info(e); 30 | } 31 | try{ 32 | eval(ice.ASSERT("3 < 2")); 33 | }catch(e){ 34 | ice.info(e); 35 | } 36 | 37 | // simulated test 38 | 39 | simulator("info", ["Info"]); 40 | simulator("warn", ["Warn"]); 41 | try{ 42 | simulator("error", ["Error"]); 43 | }catch(e){ 44 | simulator("info", [e]); 45 | } 46 | 47 | simulator("test", [1 < 2, "Test #1"]); 48 | simulator("TEST", ["1 < 2"]); 49 | simulator("test", [3 < 2, "Test #2"]); 50 | simulator("TEST", ["3 < 2"]); 51 | 52 | simulator("assert", [1 < 2, "Test #1"]); 53 | simulator("ASSERT", ["1 < 2"]); 54 | try{ 55 | simulator("assert", [3 < 2, "Test #2"]); 56 | }catch(e){ 57 | simulator("info", [e]); 58 | } 59 | try{ 60 | simulator("ASSERT", ["3 < 2"]); 61 | }catch(e){ 62 | simulator("info", [e]); 63 | } 64 | }); 65 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # ICE 2 | 3 | [![Build status][travis-image]][travis-url] 4 | [![Dependencies][deps-image]][deps-url] 5 | [![devDependencies][dev-deps-image]][dev-deps-url] 6 | [![NPM version][npm-image]][npm-url] 7 | 8 | ICE: logging, debugging, and assert facility. 9 | 10 | This project is being tested as a part of [heya-unit](https://github.com/heya/unit): 11 | 12 | [![Build status][travis-image2]][travis-url2] 13 | [![Dependencies][deps-image2]][deps-url2] 14 | [![devDependencies][dev-deps-image2]][dev-deps-url2] 15 | [![NPM version][npm-image2]][npm-url2] 16 | 17 | 18 | ## How to install 19 | 20 | If you plan to use it in your [node.js](http://nodejs.org) project install it 21 | like this: 22 | 23 | ``` 24 | npm install heya-ice 25 | ``` 26 | 27 | For your browser-based projects I suggest to use [volo.js](http://volojs.org): 28 | 29 | ``` 30 | volo install heya/ice heya-ice 31 | ``` 32 | 33 | 34 | [npm-image]: https://img.shields.io/npm/v/heya-ice.svg 35 | [npm-url]: https://npmjs.org/package/heya-ice 36 | [deps-image]: https://img.shields.io/david/heya/ice.svg 37 | [deps-url]: https://david-dm.org/heya/ice 38 | [dev-deps-image]: https://img.shields.io/david/dev/heya/ice.svg 39 | [dev-deps-url]: https://david-dm.org/heya/ice#info=devDependencies 40 | [travis-image]: https://img.shields.io/travis/heya/ice.svg 41 | [travis-url]: https://travis-ci.org/heya/ice 42 | 43 | [npm-image2]: https://img.shields.io/npm/v/heya-unit.svg 44 | [npm-url2]: https://npmjs.org/package/heya-unit 45 | [deps-image2]: https://img.shields.io/david/heya/unit.svg 46 | [deps-url2]: https://david-dm.org/heya/unit 47 | [dev-deps-image2]: https://img.shields.io/david/dev/heya/unit.svg 48 | [dev-deps-url2]: https://david-dm.org/heya/unit#info=devDependencies 49 | [travis-image2]: https://img.shields.io/travis/heya/unit.svg 50 | [travis-url2]: https://travis-ci.org/heya/unit 51 | -------------------------------------------------------------------------------- /dist/assert.js: -------------------------------------------------------------------------------- 1 | (function(_,f){window.heya.ice.assert=f(window.heya.ice.main);}) 2 | (["./main"], function(ice){ 3 | "use strict"; 4 | 5 | function quoteString(text){ 6 | return text.replace(/['"\\]/g, "\\$&"); 7 | } 8 | 9 | function showVariables(code, selfName){ 10 | // borrowed from heya-ctr / lambda.js / crackLambda() 11 | var vars = code. 12 | replace(/(?:\b[A-Z]|\.[a-zA-Z_$])[a-zA-Z_$\d]*\b|\b[a-zA-Z_$][a-zA-Z_$\d]*:|\b(?:function|return|if|else|switch|case|while|for|do|break|continue|var|try|catch|finally|throw|with|debugger|default|this|true|false|null|undefined|typeof|instanceof|in|delete|new|void|arguments|decodeURI|decodeURIComponent|encodeURI|encodeURIComponent|escape|eval|isFinite|isNaN|parseFloat|parseInt|unescape|window|document)\b|'(?:[^'\\]|\\.)*'|"(?:[^"\\]|\\.)*"/g, ""). 13 | match(/(\b[a-z_$][a-z_$\d]*\b)/gi) || []; 14 | var result = [], resultSet = {}; 15 | for(var i = 0, n = vars.length; i < n; ++i){ 16 | var name = vars[i], key = "-" + name; 17 | if(name != selfName && !resultSet[key]){ 18 | result.push("'" + vars[i] + "':" + vars[i]); 19 | resultSet[key] = 1; 20 | } 21 | } 22 | return "{" + result.join(",") + "}"; 23 | } 24 | 25 | ice.Ice.prototype._addCond = function addConditional(Ice, level, name){ 26 | // function version 27 | Ice.prototype[name] = function assert(condition, text, custom){ 28 | if(condition){ return; } 29 | // if fails 30 | if(typeof text == "string"){ 31 | return this._log(name, text, null, custom || null, new Error("LOG")); 32 | } 33 | return this._log(name, null, null, text || custom || null, new Error("LOG")); 34 | }; 35 | // eval version 36 | Ice.prototype[name.toUpperCase()] = function assert(condition, text){ 37 | return "if(!(" + condition + ")){ " + (text || this.selfName || "ice") + "._log('" + name + 38 | "', null, '" + quoteString(condition) + "', " + 39 | showVariables(condition, text || this.selfName || "ice") + ", new Error('LOG')); }"; 40 | }; 41 | }; 42 | 43 | ice._addCond(ice.Ice, 300, "assert"); 44 | 45 | return ice; 46 | }); 47 | -------------------------------------------------------------------------------- /assert.js: -------------------------------------------------------------------------------- 1 | /* UMD.define */ (typeof define=="function"&&define||function(d,f,m){m={module:module,require:require};module.exports=f.apply(null,d.map(function(n){return m[n]||require(n)}))}) 2 | (["./main"], function(ice){ 3 | "use strict"; 4 | 5 | function quoteString(text){ 6 | return text.replace(/['"\\]/g, "\\$&"); 7 | } 8 | 9 | function showVariables(code, selfName){ 10 | // borrowed from heya-ctr / lambda.js / crackLambda() 11 | var vars = code. 12 | replace(/(?:\b[A-Z]|\.[a-zA-Z_$])[a-zA-Z_$\d]*\b|\b[a-zA-Z_$][a-zA-Z_$\d]*:|\b(?:function|return|if|else|switch|case|while|for|do|break|continue|var|try|catch|finally|throw|with|debugger|default|this|true|false|null|undefined|typeof|instanceof|in|delete|new|void|arguments|decodeURI|decodeURIComponent|encodeURI|encodeURIComponent|escape|eval|isFinite|isNaN|parseFloat|parseInt|unescape|window|document)\b|'(?:[^'\\]|\\.)*'|"(?:[^"\\]|\\.)*"/g, ""). 13 | match(/(\b[a-z_$][a-z_$\d]*\b)/gi) || []; 14 | var result = [], resultSet = {}; 15 | for(var i = 0, n = vars.length; i < n; ++i){ 16 | var name = vars[i], key = "-" + name; 17 | if(name != selfName && !resultSet[key]){ 18 | result.push("'" + vars[i] + "':" + vars[i]); 19 | resultSet[key] = 1; 20 | } 21 | } 22 | return "{" + result.join(",") + "}"; 23 | } 24 | 25 | ice.Ice.prototype._addCond = function addConditional(Ice, level, name){ 26 | // function version 27 | Ice.prototype[name] = function assert(condition, text, custom){ 28 | if(condition){ return; } 29 | // if fails 30 | if(typeof text == "string"){ 31 | return this._log(name, text, null, custom || null, new Error("LOG")); 32 | } 33 | return this._log(name, null, null, text || custom || null, new Error("LOG")); 34 | }; 35 | // eval version 36 | Ice.prototype[name.toUpperCase()] = function assert(condition, text){ 37 | return "if(!(" + condition + ")){ " + (text || this.selfName || "ice") + "._log('" + name + 38 | "', null, '" + quoteString(condition) + "', " + 39 | showVariables(condition, text || this.selfName || "ice") + ", new Error('LOG')); }"; 40 | }; 41 | }; 42 | 43 | ice._addCond(ice.Ice, 300, "assert"); 44 | 45 | return ice; 46 | }); 47 | -------------------------------------------------------------------------------- /dist/main.js: -------------------------------------------------------------------------------- 1 | (function(_,f,m){m={};m.id=m.filename="main.js";window.heya.ice.main=f(m,window.heya.ice.sinks.short,window.heya.ice.sinks.console,window.heya.ice.sinks.exception);}) 2 | (["module", "./sinks/short", "./sinks/console", "./sinks/exception"], 3 | function(module, shortSink, consoleSink, exceptionSink){ 4 | "use strict"; 5 | 6 | var transports = { 7 | "default": [ 8 | { 9 | filter: [0, 200], 10 | log: shortSink 11 | }, 12 | { 13 | filter: 200, 14 | log: consoleSink 15 | }, 16 | { 17 | filter: 300, 18 | log: exceptionSink 19 | } 20 | ] 21 | }, 22 | levels = { 23 | info: 0, 24 | warn: 100, 25 | test: 200, 26 | assert: 300, 27 | error: 400 28 | }, 29 | defaultIceSettings = { 30 | filter: 0, 31 | name: "ice", 32 | transport: "default" 33 | }; 34 | 35 | function Ice(meta, ice){ 36 | ice = ice || defaultIceSettings; 37 | this.filter = ice.filter || 0; 38 | this.selfName = ice.selfName || "ice"; 39 | this.transport = ice.transport || "default"; 40 | this.meta = {}; 41 | if(meta){ 42 | if(meta.id) { this.meta.id = meta.mid || meta.id || ""; } 43 | if(meta.filename){ this.meta.filename = meta.filename || meta.uri || meta.url || ""; } 44 | } 45 | } 46 | 47 | Ice.prototype = { 48 | declaredClass: "ice/Ice", 49 | Ice: Ice, 50 | // static methods 51 | getTransports: function getTransports(){ 52 | return transports; 53 | }, 54 | getNamedTransports: function getNamedTransports(name){ 55 | return transports[name] || transports["default"]; 56 | }, 57 | setNamedTransports: function setNamedTransports(name, newTransports){ 58 | if(newTransports){ 59 | transports[name] = newTransports; 60 | }else{ 61 | delete transports[name]; 62 | } 63 | }, 64 | // main internal function, which actually logs data 65 | _log: function _log(name, text, condition, custom, excp){ 66 | // check the level 67 | var level = levels[name]; 68 | if(typeof this.filter == "number" && level < this.filter || 69 | this.filter && this.filter instanceof Array && 70 | (this.filter[0] > level || level >= this.filter[1]) || 71 | typeof this.filter == "function" && 72 | !this.filter(this, name, text, condition, custom)){ 73 | return; 74 | } 75 | // prepare meta data 76 | var meta = { 77 | name: name, 78 | level: level, 79 | stack: excp.stack || null, 80 | time: new Date() 81 | }; 82 | for(var k in this.meta){ 83 | if(this.meta.hasOwnProperty(k) && !meta[k]){ 84 | meta[k] = this.meta[k]; 85 | } 86 | } 87 | // go over transports 88 | var transports = this.getNamedTransports(this.transport); 89 | for(var i = 0; i < transports.length; ++i){ 90 | var t = transports[i]; 91 | // check the level 92 | if(typeof t.filter == "number" && level < t.filter || 93 | t.filter && t.filter instanceof Array && 94 | (t.filter[0] > level || level >= t.filter[1]) || 95 | typeof t.filter == "function" && 96 | !t.filter(this, name, text, condition, custom)){ 97 | continue; 98 | } 99 | if(t.log(this, meta, text, condition, custom)){ 100 | break; 101 | } 102 | } 103 | }, 104 | // user-level methods 105 | specialize: function specialize(meta){ 106 | return new Ice(meta, this); 107 | } 108 | }; 109 | 110 | function addLevel(Ice, level, name){ 111 | Ice.prototype[name] = function(text, custom){ 112 | var t, e; 113 | if(text && text instanceof Error){ 114 | t = text.message; 115 | e = text; 116 | }else{ 117 | t = text; 118 | e = new Error("LOG"); 119 | } 120 | this._log(name, t || "", null, custom || null, e); 121 | }; 122 | } 123 | 124 | // add standard levels 125 | addLevel(Ice, 0, "info"); 126 | addLevel(Ice, 100, "warn"); 127 | addLevel(Ice, 400, "error"); 128 | 129 | // default ice 130 | 131 | var ice = new Ice({id: "*default*"}, defaultIceSettings); 132 | 133 | // process configuration options, if available 134 | 135 | var availableSinks = { 136 | "short": shortSink, 137 | "console": consoleSink, 138 | "exception": exceptionSink 139 | }; 140 | 141 | if(typeof module.config == "function"){ 142 | var config = module.config(); 143 | if(config){ 144 | if(typeof config.filter == "number" || config.filter){ 145 | ice.filter = config.filter; 146 | } 147 | if(config.transports){ 148 | for(var k in config.transports){ 149 | if(config.transports.hasOwnProperty(k)){ 150 | var t = config.transports[k], y = []; 151 | for(var i = 0; i < t.length; ++i){ 152 | var x = t[i]; 153 | if(x.log && availableSinks.hasOwnProperty(x.log)){ 154 | y.push({filter: x.filter, log: availableSinks[x.log]}); 155 | } 156 | } 157 | ice.setNamedTransports(k, y); 158 | } 159 | } 160 | } 161 | } 162 | } 163 | 164 | return ice; 165 | }); 166 | -------------------------------------------------------------------------------- /main.js: -------------------------------------------------------------------------------- 1 | /* UMD.define */ (typeof define=="function"&&define||function(d,f,m){m={module:module,require:require};module.exports=f.apply(null,d.map(function(n){return m[n]||require(n)}))}) 2 | (["module", "./sinks/short", "./sinks/console", "./sinks/exception"], 3 | function(module, shortSink, consoleSink, exceptionSink){ 4 | "use strict"; 5 | 6 | var transports = { 7 | "default": [ 8 | { 9 | filter: [0, 200], 10 | log: shortSink 11 | }, 12 | { 13 | filter: 200, 14 | log: consoleSink 15 | }, 16 | { 17 | filter: 300, 18 | log: exceptionSink 19 | } 20 | ] 21 | }, 22 | levels = { 23 | info: 0, 24 | warn: 100, 25 | test: 200, 26 | assert: 300, 27 | error: 400 28 | }, 29 | defaultIceSettings = { 30 | filter: 0, 31 | name: "ice", 32 | transport: "default" 33 | }; 34 | 35 | function Ice(meta, ice){ 36 | ice = ice || defaultIceSettings; 37 | this.filter = ice.filter || 0; 38 | this.selfName = ice.selfName || "ice"; 39 | this.transport = ice.transport || "default"; 40 | this.meta = {}; 41 | if(meta){ 42 | if(meta.id) { this.meta.id = meta.mid || meta.id || ""; } 43 | if(meta.filename){ this.meta.filename = meta.filename || meta.uri || meta.url || ""; } 44 | } 45 | } 46 | 47 | Ice.prototype = { 48 | declaredClass: "ice/Ice", 49 | Ice: Ice, 50 | // static methods 51 | getTransports: function getTransports(){ 52 | return transports; 53 | }, 54 | getNamedTransports: function getNamedTransports(name){ 55 | return transports[name] || transports["default"]; 56 | }, 57 | setNamedTransports: function setNamedTransports(name, newTransports){ 58 | if(newTransports){ 59 | transports[name] = newTransports; 60 | }else{ 61 | delete transports[name]; 62 | } 63 | }, 64 | // main internal function, which actually logs data 65 | _log: function _log(name, text, condition, custom, excp){ 66 | // check the level 67 | var level = levels[name]; 68 | if(typeof this.filter == "number" && level < this.filter || 69 | this.filter && this.filter instanceof Array && 70 | (this.filter[0] > level || level >= this.filter[1]) || 71 | typeof this.filter == "function" && 72 | !this.filter(this, name, text, condition, custom)){ 73 | return; 74 | } 75 | // prepare meta data 76 | var meta = { 77 | name: name, 78 | level: level, 79 | stack: excp.stack || null, 80 | time: new Date() 81 | }; 82 | for(var k in this.meta){ 83 | if(this.meta.hasOwnProperty(k) && !meta[k]){ 84 | meta[k] = this.meta[k]; 85 | } 86 | } 87 | // go over transports 88 | var transports = this.getNamedTransports(this.transport); 89 | for(var i = 0; i < transports.length; ++i){ 90 | var t = transports[i]; 91 | // check the level 92 | if(typeof t.filter == "number" && level < t.filter || 93 | t.filter && t.filter instanceof Array && 94 | (t.filter[0] > level || level >= t.filter[1]) || 95 | typeof t.filter == "function" && 96 | !t.filter(this, name, text, condition, custom)){ 97 | continue; 98 | } 99 | if(t.log(this, meta, text, condition, custom)){ 100 | break; 101 | } 102 | } 103 | }, 104 | // user-level methods 105 | specialize: function specialize(meta){ 106 | return new Ice(meta, this); 107 | } 108 | }; 109 | 110 | function addLevel(Ice, level, name){ 111 | Ice.prototype[name] = function(text, custom){ 112 | var t, e; 113 | if(text && text instanceof Error){ 114 | t = text.message; 115 | e = text; 116 | }else{ 117 | t = text; 118 | e = new Error("LOG"); 119 | } 120 | this._log(name, t || "", null, custom || null, e); 121 | }; 122 | } 123 | 124 | // add standard levels 125 | addLevel(Ice, 0, "info"); 126 | addLevel(Ice, 100, "warn"); 127 | addLevel(Ice, 400, "error"); 128 | 129 | // default ice 130 | 131 | var ice = new Ice({id: "*default*"}, defaultIceSettings); 132 | 133 | // process configuration options, if available 134 | 135 | var availableSinks = { 136 | "short": shortSink, 137 | "console": consoleSink, 138 | "exception": exceptionSink 139 | }; 140 | 141 | if(typeof module.config == "function"){ 142 | var config = module.config(); 143 | if(config){ 144 | if(typeof config.filter == "number" || config.filter){ 145 | ice.filter = config.filter; 146 | } 147 | if(config.transports){ 148 | for(var k in config.transports){ 149 | if(config.transports.hasOwnProperty(k)){ 150 | var t = config.transports[k], y = []; 151 | for(var i = 0; i < t.length; ++i){ 152 | var x = t[i]; 153 | if(x.log && availableSinks.hasOwnProperty(x.log)){ 154 | y.push({filter: x.filter, log: availableSinks[x.log]}); 155 | } 156 | } 157 | ice.setNamedTransports(k, y); 158 | } 159 | } 160 | } 161 | } 162 | } 163 | 164 | return ice; 165 | }); 166 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | This library is available under *either* the terms of the modified BSD license 2 | *or* the Academic Free License version 2.1. As a recipient of this work, you 3 | may choose which license to receive this code under. No external contributions 4 | are allowed under licenses which are fundamentally incompatible with the AFL 5 | or BSD licenses that this library is distributed under. 6 | 7 | The text of the AFL and BSD licenses is reproduced below. 8 | 9 | ------------------------------------------------------------------------------- 10 | The "New" BSD License: 11 | ********************** 12 | 13 | Copyright (c) 2005-2012, Eugene Lazutkin 14 | All rights reserved. 15 | 16 | Redistribution and use in source and binary forms, with or without 17 | modification, are permitted provided that the following conditions are met: 18 | 19 | * Redistributions of source code must retain the above copyright notice, this 20 | list of conditions and the following disclaimer. 21 | * Redistributions in binary form must reproduce the above copyright notice, 22 | this list of conditions and the following disclaimer in the documentation 23 | and/or other materials provided with the distribution. 24 | * Neither the name of Eugene Lazutkin nor the names of other contributors 25 | may be used to endorse or promote products derived from this software 26 | without specific prior written permission. 27 | 28 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 29 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 30 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 31 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE 32 | FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 33 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 34 | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 35 | CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 36 | OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 37 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 38 | 39 | ------------------------------------------------------------------------------- 40 | The Academic Free License, v. 2.1: 41 | ********************************** 42 | 43 | This Academic Free License (the "License") applies to any original work of 44 | authorship (the "Original Work") whose owner (the "Licensor") has placed the 45 | following notice immediately following the copyright notice for the Original 46 | Work: 47 | 48 | Licensed under the Academic Free License version 2.1 49 | 50 | 1) Grant of Copyright License. Licensor hereby grants You a world-wide, 51 | royalty-free, non-exclusive, perpetual, sublicenseable license to do the 52 | following: 53 | 54 | a) to reproduce the Original Work in copies; 55 | 56 | b) to prepare derivative works ("Derivative Works") based upon the Original 57 | Work; 58 | 59 | c) to distribute copies of the Original Work and Derivative Works to the 60 | public; 61 | 62 | d) to perform the Original Work publicly; and 63 | 64 | e) to display the Original Work publicly. 65 | 66 | 2) Grant of Patent License. Licensor hereby grants You a world-wide, 67 | royalty-free, non-exclusive, perpetual, sublicenseable license, under patent 68 | claims owned or controlled by the Licensor that are embodied in the Original 69 | Work as furnished by the Licensor, to make, use, sell and offer for sale the 70 | Original Work and Derivative Works. 71 | 72 | 3) Grant of Source Code License. The term "Source Code" means the preferred 73 | form of the Original Work for making modifications to it and all available 74 | documentation describing how to modify the Original Work. Licensor hereby 75 | agrees to provide a machine-readable copy of the Source Code of the Original 76 | Work along with each copy of the Original Work that Licensor distributes. 77 | Licensor reserves the right to satisfy this obligation by placing a 78 | machine-readable copy of the Source Code in an information repository 79 | reasonably calculated to permit inexpensive and convenient access by You for as 80 | long as Licensor continues to distribute the Original Work, and by publishing 81 | the address of that information repository in a notice immediately following 82 | the copyright notice that applies to the Original Work. 83 | 84 | 4) Exclusions From License Grant. Neither the names of Licensor, nor the names 85 | of any contributors to the Original Work, nor any of their trademarks or 86 | service marks, may be used to endorse or promote products derived from this 87 | Original Work without express prior written permission of the Licensor. Nothing 88 | in this License shall be deemed to grant any rights to trademarks, copyrights, 89 | patents, trade secrets or any other intellectual property of Licensor except as 90 | expressly stated herein. No patent license is granted to make, use, sell or 91 | offer to sell embodiments of any patent claims other than the licensed claims 92 | defined in Section 2. No right is granted to the trademarks of Licensor even if 93 | such marks are included in the Original Work. Nothing in this License shall be 94 | interpreted to prohibit Licensor from licensing under different terms from this 95 | License any Original Work that Licensor otherwise would have a right to 96 | license. 97 | 98 | 5) This section intentionally omitted. 99 | 100 | 6) Attribution Rights. You must retain, in the Source Code of any Derivative 101 | Works that You create, all copyright, patent or trademark notices from the 102 | Source Code of the Original Work, as well as any notices of licensing and any 103 | descriptive text identified therein as an "Attribution Notice." You must cause 104 | the Source Code for any Derivative Works that You create to carry a prominent 105 | Attribution Notice reasonably calculated to inform recipients that You have 106 | modified the Original Work. 107 | 108 | 7) Warranty of Provenance and Disclaimer of Warranty. Licensor warrants that 109 | the copyright in and to the Original Work and the patent rights granted herein 110 | by Licensor are owned by the Licensor or are sublicensed to You under the terms 111 | of this License with the permission of the contributor(s) of those copyrights 112 | and patent rights. Except as expressly stated in the immediately proceeding 113 | sentence, the Original Work is provided under this License on an "AS IS" BASIS 114 | and WITHOUT WARRANTY, either express or implied, including, without limitation, 115 | the warranties of NON-INFRINGEMENT, MERCHANTABILITY or FITNESS FOR A PARTICULAR 116 | PURPOSE. THE ENTIRE RISK AS TO THE QUALITY OF THE ORIGINAL WORK IS WITH YOU. 117 | This DISCLAIMER OF WARRANTY constitutes an essential part of this License. No 118 | license to Original Work is granted hereunder except under this disclaimer. 119 | 120 | 8) Limitation of Liability. Under no circumstances and under no legal theory, 121 | whether in tort (including negligence), contract, or otherwise, shall the 122 | Licensor be liable to any person for any direct, indirect, special, incidental, 123 | or consequential damages of any character arising as a result of this License 124 | or the use of the Original Work including, without limitation, damages for loss 125 | of goodwill, work stoppage, computer failure or malfunction, or any and all 126 | other commercial damages or losses. This limitation of liability shall not 127 | apply to liability for death or personal injury resulting from Licensor's 128 | negligence to the extent applicable law prohibits such limitation. Some 129 | jurisdictions do not allow the exclusion or limitation of incidental or 130 | consequential damages, so this exclusion and limitation may not apply to You. 131 | 132 | 9) Acceptance and Termination. If You distribute copies of the Original Work or 133 | a Derivative Work, You must make a reasonable effort under the circumstances to 134 | obtain the express assent of recipients to the terms of this License. Nothing 135 | else but this License (or another written agreement between Licensor and You) 136 | grants You permission to create Derivative Works based upon the Original Work 137 | or to exercise any of the rights granted in Section 1 herein, and any attempt 138 | to do so except under the terms of this License (or another written agreement 139 | between Licensor and You) is expressly prohibited by U.S. copyright law, the 140 | equivalent laws of other countries, and by international treaty. Therefore, by 141 | exercising any of the rights granted to You in Section 1 herein, You indicate 142 | Your acceptance of this License and all of its terms and conditions. 143 | 144 | 10) Termination for Patent Action. This License shall terminate automatically 145 | and You may no longer exercise any of the rights granted to You by this License 146 | as of the date You commence an action, including a cross-claim or counterclaim, 147 | against Licensor or any licensee alleging that the Original Work infringes a 148 | patent. This termination provision shall not apply for an action alleging 149 | patent infringement by combinations of the Original Work with other software or 150 | hardware. 151 | 152 | 11) Jurisdiction, Venue and Governing Law. Any action or suit relating to this 153 | License may be brought only in the courts of a jurisdiction wherein the 154 | Licensor resides or in which Licensor conducts its primary business, and under 155 | the laws of that jurisdiction excluding its conflict-of-law provisions. The 156 | application of the United Nations Convention on Contracts for the International 157 | Sale of Goods is expressly excluded. Any use of the Original Work outside the 158 | scope of this License or after its termination shall be subject to the 159 | requirements and penalties of the U.S. Copyright Act, 17 U.S.C. § 101 et 160 | seq., the equivalent laws of other countries, and international treaty. This 161 | section shall survive the termination of this License. 162 | 163 | 12) Attorneys Fees. In any action to enforce the terms of this License or 164 | seeking damages relating thereto, the prevailing party shall be entitled to 165 | recover its costs and expenses, including, without limitation, reasonable 166 | attorneys' fees and costs incurred in connection with such action, including 167 | any appeal of such action. This section shall survive the termination of this 168 | License. 169 | 170 | 13) Miscellaneous. This License represents the complete agreement concerning 171 | the subject matter hereof. If any provision of this License is held to be 172 | unenforceable, such provision shall be reformed only to the extent necessary to 173 | make it enforceable. 174 | 175 | 14) Definition of "You" in This License. "You" throughout this License, whether 176 | in upper or lower case, means an individual or a legal entity exercising rights 177 | under, and complying with all of the terms of, this License. For legal 178 | entities, "You" includes any entity that controls, is controlled by, or is 179 | under common control with you. For purposes of this definition, "control" means 180 | (i) the power, direct or indirect, to cause the direction or management of such 181 | entity, whether by contract or otherwise, or (ii) ownership of fifty percent 182 | (50%) or more of the outstanding shares, or (iii) beneficial ownership of such 183 | entity. 184 | 185 | 15) Right to Use. You may use the Original Work in all ways not otherwise 186 | restricted or conditioned by this License or by law, and Licensor promises not 187 | to interfere with or be responsible for such uses by You. 188 | 189 | This license is Copyright (C) 2003-2004 Lawrence E. Rosen. All rights reserved. 190 | Permission is hereby granted to copy and distribute this license without 191 | modification. This license may not be modified without the express written 192 | permission of its copyright owner. 193 | --------------------------------------------------------------------------------