delogger 0.1.2 → 0.1.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +9 -0
- data/Gemfile +3 -0
- data/README.md +1 -1
- data/assets/javascripts/delogger.coffee +93 -0
- data/bin/compile +12 -0
- data/delogger.gemspec +21 -0
- data/images/example.png +0 -0
- data/lib/delogger.rb +7 -0
- data/lib/delogger/rails.rb +6 -0
- data/lib/delogger/rails/engine.rb +6 -0
- data/lib/delogger/version.rb +3 -0
- metadata +11 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a4025911c0f40b910cdd1b90fe53902113639d16
|
4
|
+
data.tar.gz: 1d744eb25a0eeab3623284c222f718192ac77703
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a303b39fa9c473dbbb96a8c68d5db8a7c618deab4709a30164758db5985b0f5be064fe0846855722b05d9fe4dc651e26522364f9b365f07f31ee75b82e20555f
|
7
|
+
data.tar.gz: 30dddf9265a80db63e5ba9eecec4fcd0cf565e3c6d5c0609fe4e2ad379ca5f5b4459527e88634085bd90aa2a0c059e73d5ad4046f0daf410db378d4261568a0e
|
data/.gitignore
ADDED
data/Gemfile
ADDED
data/README.md
CHANGED
@@ -0,0 +1,93 @@
|
|
1
|
+
class @DeLogger
|
2
|
+
@debug: (args...) ->
|
3
|
+
print('debug', getStyle('badge', 'debug'), args...)
|
4
|
+
|
5
|
+
@warn: (args...) ->
|
6
|
+
print('warn', getStyle('badge', 'warn'), args...)
|
7
|
+
|
8
|
+
@error: (args...) ->
|
9
|
+
print('error', getStyle('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('.')
|
51
|
+
css = getStyle(classes..., 'after')
|
52
|
+
return ["%c#{match[1]}", css]
|
53
|
+
["%c#{string}", getStyle('default', 'after')]
|
54
|
+
|
55
|
+
getStyle = (classes...) ->
|
56
|
+
style = ''
|
57
|
+
for klass in classes
|
58
|
+
style += ("#{key}:#{value};" for key, value of styles()[klass]).join('')
|
59
|
+
style
|
60
|
+
|
61
|
+
styles = ->
|
62
|
+
'default': {},
|
63
|
+
|
64
|
+
'badge': {
|
65
|
+
'color': 'white',
|
66
|
+
'background': 'black',
|
67
|
+
'border-radius': '9px',
|
68
|
+
'padding': '1px 5px'
|
69
|
+
},
|
70
|
+
|
71
|
+
'debug': {
|
72
|
+
'background': 'blue'
|
73
|
+
},
|
74
|
+
|
75
|
+
'warn': {
|
76
|
+
'background': 'orange'
|
77
|
+
},
|
78
|
+
|
79
|
+
'error': {
|
80
|
+
'background': 'red'
|
81
|
+
},
|
82
|
+
|
83
|
+
'bold': {
|
84
|
+
'font-weight': 'bold'
|
85
|
+
},
|
86
|
+
|
87
|
+
'italic': {
|
88
|
+
'font-style': 'italic'
|
89
|
+
},
|
90
|
+
|
91
|
+
'after': {
|
92
|
+
'margin-left': '3px'
|
93
|
+
}
|
data/bin/compile
ADDED
@@ -0,0 +1,12 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
require 'bundler/setup'
|
3
|
+
Bundler.setup
|
4
|
+
|
5
|
+
require 'coffee-script'
|
6
|
+
require 'uglifier'
|
7
|
+
|
8
|
+
IN_PATH = 'assets/javascripts/delogger.coffee'
|
9
|
+
OUT_PATH = 'vendor/assets/javascripts/delogger.js'
|
10
|
+
|
11
|
+
compiled_coffee = CoffeeScript.compile(File.read(IN_PATH))
|
12
|
+
File.write OUT_PATH, Uglifier.compile(compiled_coffee)
|
data/delogger.gemspec
ADDED
@@ -0,0 +1,21 @@
|
|
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].each { |x| spec.add_development_dependency x }
|
21
|
+
end
|
data/images/example.png
ADDED
Binary file
|
data/lib/delogger.rb
ADDED
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.1.
|
4
|
+
version: 0.1.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Alexander Komarov
|
@@ -73,8 +73,18 @@ executables: []
|
|
73
73
|
extensions: []
|
74
74
|
extra_rdoc_files: []
|
75
75
|
files:
|
76
|
+
- ".gitignore"
|
77
|
+
- Gemfile
|
76
78
|
- LICENSE.txt
|
77
79
|
- README.md
|
80
|
+
- assets/javascripts/delogger.coffee
|
81
|
+
- bin/compile
|
82
|
+
- delogger.gemspec
|
83
|
+
- images/example.png
|
84
|
+
- lib/delogger.rb
|
85
|
+
- lib/delogger/rails.rb
|
86
|
+
- lib/delogger/rails/engine.rb
|
87
|
+
- lib/delogger/version.rb
|
78
88
|
- vendor/assets/javascripts/delogger.js
|
79
89
|
homepage: https://github.com/akxcv/delogger
|
80
90
|
licenses:
|