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 +4 -4
- data/README.md +30 -6
- data/lib/delogger/version.rb +1 -1
- data/vendor/assets/javascripts/delogger.js +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5544704780ecc02bc3ba2112b80aa84790d08837
|
4
|
+
data.tar.gz: cfefd886cc01a20c808a932436a05719f9501132
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|

|
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`:
|
46
|
-
|
47
|
-
- `
|
48
|
-
|
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
|

|
61
85
|
|
62
|
-
|
86
|
+
### Color classes
|
63
87
|
|
64
88
|
DeLogger supports following color classes (both for badges and normal text):
|
65
89
|
- `.blue`
|
data/lib/delogger/version.rb
CHANGED
@@ -1 +1 @@
|
|
1
|
-
(function(){var t=[].slice;this.DeLogger=function(){function
|
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);
|