delogger 0.3.0.alpha2 → 0.3.0.alpha3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 2772a74e4b98f748a8eea9b0111ccd8cf8de6ea6
4
- data.tar.gz: 2b6d4c33da21cb6634debe5ae076c88fb9252171
3
+ metadata.gz: 5544704780ecc02bc3ba2112b80aa84790d08837
4
+ data.tar.gz: cfefd886cc01a20c808a932436a05719f9501132
5
5
  SHA512:
6
- metadata.gz: 2cbc27a273ed6c5251a15646085dcdca02655e9ab8fdd6546caddbeb8bf7ceb316d9bca3a60b5c21794a9f9718e3951039d34246889b5c967a95ee00fb32e4e2
7
- data.tar.gz: 3bfce17107d90729aeaf6bee941213f514ed831ac0b703fba46e85975d42dca19a6cee5d71cd236a9fb45561dead506b011f187780636e4930561a1082ea0555
6
+ metadata.gz: 154795b61f06d5995ab098879b682015db734511f745c22d796ba3a19673cd100898767e8b110b2887de57985d1ab0856880a5119c56afb7004efd8f8ce9f9ad
7
+ data.tar.gz: 2bd8d6e488a6790210d6539d2d7ad346b4469734be2a5fa53a666e97547382187e5a1453f3b1dc6c9eabce7cdc778584e59f1af799796790b14c7c33e657969a
data/README.md CHANGED
@@ -4,6 +4,8 @@
4
4
 
5
5
  This gem is a simple wrapper for the browser's console. It can be turned off both globally
6
6
  (e.x. production environment) and locally. It also supports CSS formatting.
7
+
8
+
7
9
  ![Demo](/images/demo.png?raw=true)
8
10
 
9
11
  ## Getting Started
@@ -39,13 +41,35 @@ logger = new DeLogger
39
41
  See also: [options](#options).
40
42
 
41
43
  By default, DeLogger is **disabled on the client side**. To enable it, use `logger.enable()` in your
42
- console. You can disable it again using `logger.disable()`.
44
+ console. You can disable it again using `logger.disable()`. DeLogger is using browser's `localStorage`,
45
+ so you only have to enable/disable it once on your website.
43
46
 
44
47
  DeLogger supports same output methods as console:
45
- - `log`, `debug`: ![debug][/images/debug.png?raw=true]
46
- - `info`: ![info][/images/info.png?raw=true]
47
- - `warn`: ![warn][/images/warn.png?raw=true]
48
- - `error`: ![error][/images/error.png?raw=true]
48
+ - `log`, `debug`:
49
+ ![debug][/images/debug.png?raw=true]
50
+ - `info`:
51
+ ![info][/images/info.png?raw=true]
52
+ - `warn`:
53
+ ![warn][/images/warn.png?raw=true]
54
+ - `error`:
55
+ ![error][/images/error.png?raw=true]
56
+
57
+ ### Options
58
+
59
+ You can pass options to DeLogger upon initialization:
60
+ ```js
61
+ logger = DeLogger.new({ disabled: false, formatStrings: true })
62
+ ```
63
+ - `disabled`: You can disable the logger globally if you want to. Normally, though, `logger.disable()`
64
+ should be enough.
65
+ - `formatStrings`: Controls whether strings should be formatted (see [formatting](#formatting)) or
66
+ left unchanged.
67
+
68
+ ### Focus mode
69
+
70
+ If you want to debug a certain block of code, but your console is flooded with messages, you can
71
+ enter the Focus mode with `logger.focus()`. In this mode, you will only see "focused" output. To
72
+ produce "focused" output, use `logger.focus('my text')`. To leave Focus mode, use `logger.unfocus()`.
49
73
 
50
74
  ## Formatting
51
75
 
@@ -59,7 +83,7 @@ logger.log("(MyClass#myMethod).badge.italic (@akxcv).badge.orange (bold).bold",
59
83
  ```
60
84
  ![Example output](/images/formatting.png?raw=true)
61
85
 
62
- ## Color classes
86
+ ### Color classes
63
87
 
64
88
  DeLogger supports following color classes (both for badges and normal text):
65
89
  - `.blue`
@@ -1,3 +1,3 @@
1
1
  module DeLogger
2
- VERSION = "0.3.0.alpha2"
2
+ VERSION = "0.3.0.alpha3"
3
3
  end
@@ -1 +1 @@
1
- (function(){var t=[].slice;this.DeLogger=function(){function n(t){var n,e;null==t&&(t={}),n=t.disabled||!1,e=null==t.formatStrings||t.formatStrings,this.settings={disabled:n,formatStrings:e}}var e,r,o;return n.prototype.log=function(){return this.print.apply(this,["log"].concat(t.call(arguments)))},n.prototype.info=function(){return this.print.apply(this,["info"].concat(t.call(arguments)))},n.prototype.debug=function(){return this.print.apply(this,["debug"].concat(t.call(arguments)))},n.prototype.warn=function(){return this.print.apply(this,["warn"].concat(t.call(arguments)))},n.prototype.error=function(){return this.print.apply(this,["error"].concat(t.call(arguments)))},n.prototype.enable=function(){return localStorage.setItem("deloggerEnabled",!0)},n.prototype.disable=function(){return localStorage.removeItem("deloggerEnabled")},n.prototype.print=function(){var n,e,o,l,i,a,c,p,s,u,g;if(a=arguments[0],e=2<=arguments.length?t.call(arguments,1):[],this.canPrint()){for(g="",u=[],o=0,l=0,i=e.length;l<i&&(n=e[l],"string"==typeof n&&this.settings.formatStrings);l++)c=r(n),p=c[0],s=c[1],g+=p,u.push.apply(u,s),o+=1;return e.splice(0,o),console[a].apply(console,[g].concat(t.call(u),t.call(e)))}},n.prototype.canPrint=function(){return!this.settings.disabled&&null!=localStorage.deloggerEnabled},r=function(t){var n,r,o;for(n=[],o=/\(([^\(\)]+)\)(\.[\.\w]+)/;r=t.match(o);)n.push(e(r[2].split(".").join(" "))),n.push(e("default")),t=t.replace(o,"%c"+r[1]+"%c");return[t,n]},e=function(t){var n,e,r,l;return e=document.createElement("div"),e.id="delogger",e.className=t,e.style="display: none;",document.getElementsByTagName("body")[0].appendChild(e),n=getComputedStyle(e),l=function(){var t,e,l;for(l=[],t=0,e=o.length;t<e;t++)r=o[t],l.push(r+":"+n.getPropertyValue(r));return l}().join(";"),e.parentNode.removeChild(e),l},o=["margin-right","color","background-color","border-radius","padding","font-weight","font-style"],n}()}).call(this);
1
+ (function(){var t=[].slice;this.DeLogger=function(){function e(t){var e,o;null==t&&(t={}),e=t.disabled||!1,o=null==t.formatStrings||t.formatStrings,this.settings={disabled:e,formatStrings:o}}var o,n,r;return e.prototype.log=function(){return this.print.apply(this,["log"].concat(t.call(arguments)))},e.prototype.info=function(){return this.print.apply(this,["info"].concat(t.call(arguments)))},e.prototype.debug=function(){return this.print.apply(this,["debug"].concat(t.call(arguments)))},e.prototype.warn=function(){return this.print.apply(this,["warn"].concat(t.call(arguments)))},e.prototype.error=function(){return this.print.apply(this,["error"].concat(t.call(arguments)))},e.prototype.enable=function(){return localStorage.setItem("deloggerEnabled",!0)},e.prototype.disable=function(){return localStorage.removeItem("deloggerEnabled")},e.prototype.focus=function(){return arguments.length<1?localStorage.setItem("deloggerFocus",!0):this.print.apply(this,["focus"].concat(t.call(arguments)))},e.prototype.unfocus=function(){return localStorage.removeItem("deloggerFocus")},e.prototype.print=function(){var e,r,l,a,c,i,u,p,s,g,d;if(i=arguments[0],r=2<=arguments.length?t.call(arguments,1):[],this.canPrint(i)){for(d="",g=[],l=0,"focus"===i&&(d+="%cFOCUS%c ",g.push(o("badge blue bold")),g.push(o("default"))),a=0,c=r.length;a<c&&(e=r[a],"string"==typeof e&&this.settings.formatStrings);a++)u=n(e),p=u[0],s=u[1],d+=p,g.push.apply(g,s),l+=1;return r.splice(0,l),"focus"===i&&(i="log"),console[i].apply(console,[d].concat(t.call(g),t.call(r)))}},e.prototype.canPrint=function(t){return!this.settings.disabled&&null!=localStorage.deloggerEnabled&&("focus"===t||null==localStorage.deloggerFocus)},n=function(t){var e,n,r;for(e=[],r=/\(([^\(\)]+)\)(\.[\.\w]+)/;n=t.match(r);)e.push(o(n[2].split(".").join(" "))),e.push(o("default")),t=t.replace(r,"%c"+n[1]+"%c");return[t,e]},o=function(t){var e,o,n,l;return o=document.createElement("div"),o.id="delogger",o.className=t,o.style="display: none;",document.getElementsByTagName("body")[0].appendChild(o),e=getComputedStyle(o),l=function(){var t,o,l;for(l=[],t=0,o=r.length;t<o;t++)n=r[t],l.push(n+":"+e.getPropertyValue(n));return l}().join(";"),o.parentNode.removeChild(o),l},r=["margin-right","color","background-color","border-radius","padding","font-weight","font-style"],e}()}).call(this);
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: delogger
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0.alpha2
4
+ version: 0.3.0.alpha3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Alexander Komarov