delogger 0.2.1 → 0.3.0.alpha1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: ec79336b89d1bd048e47fd1740706bb6ec0e41fb
4
- data.tar.gz: 7190f5b8f2bd83fce6f463b5df60d717814b486e
3
+ metadata.gz: dba07624ea89cafdd1db84f72c879abaf0472637
4
+ data.tar.gz: 13cb174e168c085a6c420bb09e16eeae6dbfb9a8
5
5
  SHA512:
6
- metadata.gz: ec68b265b5d8412a85437be839f0cbd7f43a2013deed9698f8b2d92fde1e1547870be64f61d7c3085e46407d232c7237df9ee9f989fa38279cdcd17d3588f437
7
- data.tar.gz: 84e147d6b7675326d54622f5cb04a752d918f163dda408d0ed35d99a8d1d3e46a6e4aff60140e61bb5137b102db89c7a8fa890e43777d9c566539e9d9f10a6ac
6
+ metadata.gz: 9d385a1820dde27ffc7a3159f3340710113e3073873ace763b7fcd0cbdb4fe83f15d9bd7f62363cf3d15c3cd0c173a2f13bb00045d7c2a98818fbf88a878ac87
7
+ data.tar.gz: 40770d16bd88cf05751bdb07be79d9896014979b5a0fcbeed41a127da79a63aaaf15f6de735399695efc8ca1a46c3970990f6a16161e5b96520af3a6802b566c
data/README.md CHANGED
@@ -2,25 +2,19 @@
2
2
 
3
3
  # Delogger
4
4
 
5
- Make your browser console beautiful. This gem is a work in progress.
5
+ This gem is a simple wrapper for the browser's console. It can be turned off both globally
6
+ (e.x. production environment) and locally. It also supports CSS formatting.
6
7
  ![Demo](/images/demo.png?raw=true)
7
8
 
8
- ## Installation
9
+ ## Getting Started
9
10
 
10
- Add this line to your application's Gemfile:
11
+ ### Rails:
11
12
 
13
+ Add the gem to your Gemfile:
12
14
  ```ruby
13
15
  gem 'delogger'
14
16
  ```
15
17
 
16
- And then execute:
17
-
18
- $ bundle
19
-
20
- Or install it yourself as:
21
-
22
- $ gem install delogger
23
-
24
18
  Add this to your `application.js`:
25
19
  ```
26
20
  //= require delogger
@@ -31,35 +25,39 @@ And `application.css`:
31
25
  *= require delogger
32
26
  ```
33
27
 
34
- ## Usage
28
+ ### Without Rails:
35
29
 
36
- These methods work similarly to `console.log`, but they support [formatting](#formatting):
37
- - `DeLogger.debug`
38
- - `DeLogger.warn`
39
- - `DeLogger.error`
30
+ Include `vendor/assets/javascripts/delogger.js` and `vendor/assets/stylesheets/delogger.css` into
31
+ your application.
40
32
 
41
- By default, DeLogger is **disabled**. To enable it, use `DeLogger.enable()`. You can disable it again
42
- using `DeLogger.disable()`.
33
+ ## Usage
43
34
 
44
- ## Logging levels
35
+ First, DeLogger has to be initialized:
36
+ ```js
37
+ logger = new DeLogger
38
+ ```
39
+ See also: [options](#options).
40
+
41
+ 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()`.
45
43
 
46
- DeLogger has three logging levels: `debug`, `warn` and `error`. Level can be set using `DeLogger.level`
47
- (default is `debug`). (TODO)
44
+ 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
49
 
49
50
  ## Formatting
50
51
 
51
- DeLogger supports string formatting. Syntax: `"(my text).class1.class2"`. Classes are specific for
52
- the logger and are not being fetched from stylesheets.
53
- Supported classes: `badge`, `debug`, `warn`, `error`, `bold`, `italic`.
52
+ DeLogger supports string formatting. Syntax: `"(my text).class1.class2"`.
53
+ Supported classes: `badge`, `bold`, `italic`.
54
54
  See also: [color classes](#color-classes).
55
55
 
56
56
  Example:
57
57
  ```js
58
- DeLogger.log("(MyClass#myMethod).badge", "(@akxcv).badge.warn", "(bold).bold", { foo: 'bar' })
58
+ logger.log("(MyClass#myMethod).badge.italic (@akxcv).badge.orange (bold).bold", { foo: 'bar' })
59
59
  ```
60
- ![Example output](/images/example.png?raw=true)
61
-
62
- TODO
60
+ ![Example output](/images/formatting.png?raw=true)
63
61
 
64
62
  ## Color classes
65
63
 
@@ -84,13 +82,12 @@ At the moment, only these attributes are supported: `margin-left`, `color`, `bac
84
82
 
85
83
  ## Development
86
84
 
87
- TODO
85
+ Modify files in the `assets` folder, compile them afterwards using `./bin/compile`.
88
86
 
89
87
  ## Contributing
90
88
 
91
89
  Bug reports and pull requests are welcome on GitHub at https://github.com/akxcv/delogger.
92
90
 
93
-
94
91
  ## License
95
92
 
96
93
  The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: delogger
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.1
4
+ version: 0.3.0.alpha1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Alexander Komarov
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-02-03 00:00:00.000000000 Z
11
+ date: 2017-02-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -80,29 +80,18 @@ dependencies:
80
80
  - - ">="
81
81
  - !ruby/object:Gem::Version
82
82
  version: '0'
83
- description: Format your browser console output with colors, badges and more
83
+ description: |-
84
+ Turn your console on and off globally or locally.
85
+ Format your output with colors and badges.
84
86
  email:
85
87
  - ak@akxcv.com
86
88
  executables: []
87
89
  extensions: []
88
90
  extra_rdoc_files: []
89
91
  files:
90
- - ".gitignore"
91
- - Gemfile
92
92
  - LICENSE.txt
93
93
  - README.md
94
- - assets/javascripts/delogger.coffee
95
- - assets/stylesheets/delogger.scss
96
- - bin/compile
97
- - delogger.gemspec
98
- - images/demo.png
99
- - images/example.png
100
94
  - lib/delogger.rb
101
- - lib/delogger/rails.rb
102
- - lib/delogger/rails/engine.rb
103
- - lib/delogger/version.rb
104
- - vendor/assets/javascripts/delogger.js
105
- - vendor/assets/stylesheets/delogger.css
106
95
  homepage: https://github.com/akxcv/delogger
107
96
  licenses:
108
97
  - MIT
@@ -118,13 +107,13 @@ required_ruby_version: !ruby/object:Gem::Requirement
118
107
  version: '0'
119
108
  required_rubygems_version: !ruby/object:Gem::Requirement
120
109
  requirements:
121
- - - ">="
110
+ - - ">"
122
111
  - !ruby/object:Gem::Version
123
- version: '0'
112
+ version: 1.3.1
124
113
  requirements: []
125
114
  rubyforge_project:
126
115
  rubygems_version: 2.6.8
127
116
  signing_key:
128
117
  specification_version: 4
129
- summary: Pretty output for browser console
118
+ summary: A simple browser console wrapper
130
119
  test_files: []
data/.gitignore DELETED
@@ -1,10 +0,0 @@
1
- /.bundle/
2
- /.yardoc
3
- /Gemfile.lock
4
- /_yardoc/
5
- /coverage/
6
- /doc/
7
- /pkg/
8
- /spec/reports/
9
- /tmp/
10
- *.gem
data/Gemfile DELETED
@@ -1,3 +0,0 @@
1
- source 'https://rubygems.org'
2
-
3
- gemspec
@@ -1,62 +0,0 @@
1
- class @DeLogger
2
- @debug: (args...) ->
3
- print('debug', computeStyle('badge debug'), args...)
4
-
5
- @warn: (args...) ->
6
- print('warn', computeStyle('badge warn'), args...)
7
-
8
- @error: (args...) ->
9
- print('error', computeStyle('badge error'), args...)
10
-
11
- @enable: ->
12
- localStorage.setItem("deloggerEnabled", true)
13
-
14
- @disable: ->
15
- localStorage.removeItem("deloggerEnabled")
16
-
17
- @setLevel: (level) ->
18
- localStorage.setItem("deloggerLevel", level)
19
-
20
- # private
21
-
22
- print = (level, initialStyles, args...) ->
23
- return unless canPrint(level)
24
- text = "%c#{level}"
25
- styles = [initialStyles]
26
- formattedArgumentCount = 0
27
-
28
- for arg in args
29
- break unless typeof arg is 'string'
30
- [string, style] = parseString(arg)
31
- text += string
32
- styles.push(style)
33
- formattedArgumentCount += 1
34
-
35
- args.splice(0, formattedArgumentCount)
36
- console.log text, styles..., args...
37
-
38
- canPrint = (level) ->
39
- localStorage.deloggerEnabled? and availableLevels().indexOf(level) != -1
40
-
41
- availableLevels = ->
42
- switch localStorage.deloggerLevel
43
- when 'debug' then ['debug', 'warn', 'error']
44
- when 'warn' then ['warn', 'error']
45
- when 'error' then ['error']
46
- else ['debug', 'warn', 'error']
47
-
48
- parseString = (string) ->
49
- if match = string.match(/^\((.+)\)(\..+)$/)
50
- classes = match[2].split('.').join(' ')
51
- return ["%c#{match[1]}", computeStyle("#{classes} after")]
52
- ["%c#{string}", computeStyle('default after')]
53
-
54
- computeStyle = (classes) ->
55
- div = $("<div id='delogger_temp' class='delogger #{classes}' style='display: none;'>")
56
- $('body').append(div)
57
- style = ("#{key}:#{value}" for key, value of div.css(supportedStyles)).join(';')
58
- $('#delogger_temp').remove()
59
- style
60
-
61
- supportedStyles = ['margin-left', 'color', 'background-color', 'border-radius', 'padding',
62
- 'font-weight', 'font-style']
@@ -1,119 +0,0 @@
1
- .delogger {
2
- color: black;
3
- background-color: transparent;
4
- border-radius: 0;
5
- padding: 0;
6
- margin-left: 0;
7
- font-weight: normal;
8
- font-style: normal;
9
-
10
- &.default {}
11
- &.after {
12
- margin-left: 3px;
13
- }
14
-
15
- &.badge {
16
- color: white;
17
- background-color: black;
18
- border-radius: 9px;
19
- padding: 1px 5px;
20
-
21
- &.debug, &.blue {
22
- color: white;
23
- background-color: blue;
24
- }
25
-
26
- &.warn, &.orange {
27
- color: white;
28
- background-color: orange;
29
- }
30
-
31
- &.error, &.red {
32
- color: white;
33
- background-color: red;
34
- }
35
-
36
- &.green {
37
- color: white;
38
- background-color: green;
39
- }
40
-
41
- &.cyan {
42
- color: gray;
43
- background-color: cyan;
44
- }
45
-
46
- &.yellow {
47
- color: gray;
48
- background-color: yellow;
49
- }
50
-
51
- &.gray {
52
- color: white;
53
- background-color: gray;
54
- }
55
-
56
- &.brown {
57
- color: white;
58
- background-color: brown;
59
- }
60
-
61
- &.purple {
62
- color: white;
63
- background-color: purple;
64
- }
65
-
66
- &.pink {
67
- color: gray;
68
- background-color: pink;
69
- }
70
- }
71
-
72
- &.blue {
73
- color: blue;
74
- }
75
-
76
- &.orange {
77
- color: orange;
78
- }
79
-
80
- &.red {
81
- color: red;
82
- }
83
-
84
- &.green {
85
- color: green;
86
- }
87
-
88
- &.cyan {
89
- color: cyan;
90
- }
91
-
92
- &.yellow {
93
- color: yellow;
94
- }
95
-
96
- &.gray {
97
- color: gray;
98
- }
99
-
100
- &.brown {
101
- color: brown;
102
- }
103
-
104
- &.purple {
105
- color: purple;
106
- }
107
-
108
- &.pink {
109
- color: pink;
110
- }
111
-
112
- &.bold {
113
- font-weight: bold;
114
- }
115
-
116
- &.italic {
117
- font-style: italic;
118
- }
119
- }
data/bin/compile DELETED
@@ -1,16 +0,0 @@
1
- #!/usr/bin/env ruby
2
- require 'bundler/setup'
3
- Bundler.setup
4
-
5
- require 'coffee-script'
6
- require 'uglifier'
7
- require 'sass'
8
-
9
- JS_IN_PATH = 'assets/javascripts/delogger.coffee'
10
- JS_OUT_PATH = 'vendor/assets/javascripts/delogger.js'
11
- CSS_IN_PATH = 'assets/stylesheets/delogger.scss'
12
- CSS_OUT_PATH = 'vendor/assets/stylesheets/delogger.css'
13
-
14
- compiled_coffee = CoffeeScript.compile(File.read(JS_IN_PATH))
15
- File.write JS_OUT_PATH, Uglifier.compile(compiled_coffee)
16
- File.write CSS_OUT_PATH, Sass.compile(File.read(CSS_IN_PATH))
data/delogger.gemspec DELETED
@@ -1,21 +0,0 @@
1
- # coding: utf-8
2
- lib = File.expand_path('../lib', __FILE__)
3
- $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
- require 'delogger/version'
5
-
6
- Gem::Specification.new do |spec|
7
- spec.name = "delogger"
8
- spec.version = DeLogger::VERSION
9
- spec.authors = ["Alexander Komarov"]
10
- spec.email = ["ak@akxcv.com"]
11
-
12
- spec.summary = %q{Pretty output for browser console}
13
- spec.description = %q{Format your browser console output with colors, badges and more}
14
- spec.homepage = "https://github.com/akxcv/delogger"
15
- spec.license = "MIT"
16
-
17
- spec.require_path = "lib"
18
- spec.files = `git ls-files`.split("\n")
19
-
20
- %w[bundler coffee-script coffee-script-source uglifier sass].each { |x| spec.add_development_dependency x }
21
- end
data/images/demo.png DELETED
Binary file
data/images/example.png DELETED
Binary file
@@ -1,6 +0,0 @@
1
- require "delogger/rails/engine"
2
-
3
- module DeLogger
4
- module Rails
5
- end
6
- end
@@ -1,6 +0,0 @@
1
- module DeLogger
2
- module Rails
3
- class Engine < ::Rails::Engine
4
- end
5
- end
6
- end
@@ -1,3 +0,0 @@
1
- module DeLogger
2
- VERSION = "0.2.1"
3
- end
@@ -1 +0,0 @@
1
- (function(){var e=[].slice;this.DeLogger=function(){function r(){}var n,l,t,o,a,c;return r.debug=function(){var r;return r=1<=arguments.length?e.call(arguments,0):[],a.apply(null,["debug",t("badge debug")].concat(e.call(r)))},r.warn=function(){var r;return r=1<=arguments.length?e.call(arguments,0):[],a.apply(null,["warn",t("badge warn")].concat(e.call(r)))},r.error=function(){var r;return r=1<=arguments.length?e.call(arguments,0):[],a.apply(null,["error",t("badge error")].concat(e.call(r)))},r.enable=function(){return localStorage.setItem("deloggerEnabled",!0)},r.disable=function(){return localStorage.removeItem("deloggerEnabled")},r.setLevel=function(e){return localStorage.setItem("deloggerLevel",e)},a=function(){var r,n,t,a,c,u,g,i,d,f,s,p;if(g=arguments[0],c=arguments[1],n=3<=arguments.length?e.call(arguments,2):[],l(g)){for(p="%c"+g,s=[c],t=0,a=0,u=n.length;a<u&&(r=n[a],"string"==typeof r);a++)i=o(r),d=i[0],f=i[1],p+=d,s.push(f),t+=1;return n.splice(0,t),console.log.apply(console,[p].concat(e.call(s),e.call(n)))}},l=function(e){return null!=localStorage.deloggerEnabled&&n().indexOf(e)!==-1},n=function(){switch(localStorage.deloggerLevel){case"debug":return["debug","warn","error"];case"warn":return["warn","error"];case"error":return["error"];default:return["debug","warn","error"]}},o=function(e){var r,n;return(n=e.match(/^\((.+)\)(\..+)$/))?(r=n[2].split(".").join(" "),["%c"+n[1],t(r+" after")]):["%c"+e,t("default after")]},t=function(e){var r,n,l,t;return r=$("<div id='delogger_temp' class='delogger "+e+"' style='display: none;'>"),$("body").append(r),l=function(){var e,l;e=r.css(c),l=[];for(n in e)t=e[n],l.push(n+":"+t);return l}().join(";"),$("#delogger_temp").remove(),l},c=["margin-left","color","background-color","border-radius","padding","font-weight","font-style"],r}()}).call(this);
@@ -1,69 +0,0 @@
1
- .delogger {
2
- color: black;
3
- background-color: transparent;
4
- border-radius: 0;
5
- padding: 0;
6
- margin-left: 0;
7
- font-weight: normal;
8
- font-style: normal; }
9
- .delogger.after {
10
- margin-left: 3px; }
11
- .delogger.badge {
12
- color: white;
13
- background-color: black;
14
- border-radius: 9px;
15
- padding: 1px 5px; }
16
- .delogger.badge.debug, .delogger.badge.blue {
17
- color: white;
18
- background-color: blue; }
19
- .delogger.badge.warn, .delogger.badge.orange {
20
- color: white;
21
- background-color: orange; }
22
- .delogger.badge.error, .delogger.badge.red {
23
- color: white;
24
- background-color: red; }
25
- .delogger.badge.green {
26
- color: white;
27
- background-color: green; }
28
- .delogger.badge.cyan {
29
- color: gray;
30
- background-color: cyan; }
31
- .delogger.badge.yellow {
32
- color: gray;
33
- background-color: yellow; }
34
- .delogger.badge.gray {
35
- color: white;
36
- background-color: gray; }
37
- .delogger.badge.brown {
38
- color: white;
39
- background-color: brown; }
40
- .delogger.badge.purple {
41
- color: white;
42
- background-color: purple; }
43
- .delogger.badge.pink {
44
- color: gray;
45
- background-color: pink; }
46
- .delogger.blue {
47
- color: blue; }
48
- .delogger.orange {
49
- color: orange; }
50
- .delogger.red {
51
- color: red; }
52
- .delogger.green {
53
- color: green; }
54
- .delogger.cyan {
55
- color: cyan; }
56
- .delogger.yellow {
57
- color: yellow; }
58
- .delogger.gray {
59
- color: gray; }
60
- .delogger.brown {
61
- color: brown; }
62
- .delogger.purple {
63
- color: purple; }
64
- .delogger.pink {
65
- color: pink; }
66
- .delogger.bold {
67
- font-weight: bold; }
68
- .delogger.italic {
69
- font-style: italic; }