customlogger 0.0.1 → 0.0.2

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: c18befff62ddf22661d0d0f258aebe52cf1870c8
4
- data.tar.gz: a89f2f5fb94e980158e4944a63a492b4da0a95f4
3
+ metadata.gz: 2e2b96431f3308d6ba56017f46516ef770d93596
4
+ data.tar.gz: e2e944144f39e7a03d484c715e37c6b83642c40f
5
5
  SHA512:
6
- metadata.gz: a6e041407899643e38debdd1ed694290eaa27491b0340d768574e5e843111d6a6da3ac015c3111beef8aa72e6300337e5c3eefc5770735eb141a1f379d92d0a1
7
- data.tar.gz: 197741d996981c4db83b5fd61dd130840520706f3974d7919dfa3b249b0f773d8f4a6ce6ed997377dd4fa5939e7ca4e3268a8041b4ac5421c749aa8b89b50546
6
+ metadata.gz: 9b4ad55827b26ee75b6a55b66d348d6cc2184c743832ab69541b413fb3c95849865d0f0bb1a90256f2411a7333b3ea0ac7136b3ff9038e9130cbcdfee4171a52
7
+ data.tar.gz: 7c938d486b8bb2f55d86ace247657439ddcbee64b1502cf39ba9b1872c7713cba6530250892fe94b6d19a30087ff575a906e4cc58325db5b2474e8b2c76cb947
data/.gitignore CHANGED
@@ -11,6 +11,7 @@ capybara-*.html
11
11
  rerun.txt
12
12
  pickle-email-*.html
13
13
  pkg/*
14
+ *.gem
14
15
 
15
16
  # TODO Comment out these rules if you are OK with secrets being uploaded to the repo
16
17
  config/initializers/secret_token.rb
@@ -19,6 +20,7 @@ config/secrets.yml
19
20
  ## Environment normalisation:
20
21
  /.bundle
21
22
  /vendor/bundle
23
+ Gemfile.lock
22
24
 
23
25
  # these should all be checked in to normalise the environment:
24
26
  # Gemfile.lock, .ruby-version, .ruby-gemset
data/README.md CHANGED
@@ -22,7 +22,11 @@ Or install it yourself as:
22
22
 
23
23
  ## Usage
24
24
 
25
- Custom Logger is very easy to use.
25
+ Custom Logger is very easy to use. Just use the module 'CustomLogger' anywhere
26
+ and log the message in a nice view friendly coloful html page. Take a look
27
+ at the examples below.
28
+
29
+ ![Example Screenshot](https://raw.githubusercontent.com/SaimonL/repo-assets/master/customlogger/all.png)
26
30
 
27
31
  #### Log error
28
32
 
@@ -30,30 +34,44 @@ Custom Logger is very easy to use.
30
34
  CustomLogger.error = 'This is an error message'
31
35
  CustomLogger.error 'This is an error message', 'Error Title'
32
36
 
37
+ ![Error Screenshot](https://raw.githubusercontent.com/SaimonL/repo-assets/master/customlogger/error.png)
38
+
33
39
  #### Log warning
34
40
 
35
41
  CustomLogger.warning 'This is an warning message'
36
42
  CustomLogger.warning = 'This is an warning message'
37
43
  CustomLogger.warning 'This is an warning message', 'Warning Title'
38
44
 
45
+ ![Warning Screenshot](https://raw.githubusercontent.com/SaimonL/repo-assets/master/customlogger/warning.png)
46
+
39
47
  #### Log debug
40
48
 
41
49
  CustomLogger.debug 'This is an debug message'
42
50
  CustomLogger.debug = 'This is an debug message'
43
51
  CustomLogger.debug 'This is an debug message', 'Debug Title'
44
52
 
53
+ ![Debug Screenshot](https://raw.githubusercontent.com/SaimonL/repo-assets/master/customlogger/debug.png)
54
+
45
55
  #### Log info
46
56
 
47
57
  CustomLogger.info 'This is an info message'
48
58
  CustomLogger.info = 'This is an info message'
49
59
  CustomLogger.info 'This is an info message', 'Info Title'
50
60
 
61
+ ![Info Screenshot](https://raw.githubusercontent.com/SaimonL/repo-assets/master/customlogger/info.png)
62
+
51
63
  #### Log raw
52
64
 
65
+ Keep in mind that raw means that no formatting is applied so if the output
66
+ is 1000 characters horizontal without any line break then that is what you
67
+ will see. Basically it is inside of a 'pre' html tag.
68
+
53
69
  CustomLogger.raw 'This is an raw message'
54
70
  CustomLogger.raw = 'This is an raw message'
55
71
  CustomLogger.raw 'This is an raw message', 'Raw Title'
56
72
 
73
+ ![Raw Screenshot](https://raw.githubusercontent.com/SaimonL/repo-assets/master/customlogger/raw.png)
74
+
57
75
  #### Clear All Logs
58
76
 
59
77
  customlogger.clear
@@ -65,9 +83,14 @@ You will find the log file in:
65
83
 
66
84
  log/customlogger.html
67
85
 
86
+
87
+ ## Running Test On Gem (Not Rails App)
88
+
89
+ bundle exec rake spec
90
+
68
91
  ## Contributing
69
92
 
70
- 1. Fork it ( https://github.com/[my-github-username]/customlogger/fork )
93
+ 1. Fork it ( https://github.com/SaimonL/CustomLogger/fork )
71
94
  2. Create your feature branch (`git checkout -b my-new-feature`)
72
95
  3. Commit your changes (`git commit -am 'Add some feature'`)
73
96
  4. Push to the branch (`git push origin my-new-feature`)
data/customlogger.gemspec CHANGED
@@ -7,7 +7,7 @@ Gem::Specification.new do |spec|
7
7
  spec.name = "customlogger"
8
8
  spec.version = Customlogger::VERSION
9
9
  spec.authors = ["Saimon Lovell"]
10
- spec.email = ["staysynchronize@gmai.com"]
10
+ spec.email = ["staysynchronize@gmail.com"]
11
11
  spec.summary = %q{Log output in to a seperate html file.}
12
12
  spec.description = %q{Have you ever wished that you could debug an output to a html nicely colored page? Now you can.}
13
13
  spec.homepage = "https://github.com/SaimonL/CustomLogger"
data/lib/customlogger.rb CHANGED
@@ -1,4 +1,5 @@
1
- require "customlogger/version"
1
+ require 'customlogger/version'
2
+ require 'customlogger/html_template'
2
3
 
3
4
  module CustomLogger
4
5
  LOOP_LIMIT = 512
@@ -9,11 +10,7 @@ module CustomLogger
9
10
  end
10
11
 
11
12
  def path
12
- if @log_path.nil?
13
- [ Dir.pwd, '/log' ].join
14
- else
15
- @log_path
16
- end
13
+ @log_path||=[ Dir.pwd, '/log' ].join
17
14
  end
18
15
 
19
16
  def file=(value)
@@ -21,11 +18,7 @@ module CustomLogger
21
18
  end
22
19
 
23
20
  def file
24
- if @file_name.nil?
25
- 'CustomLogger.html'
26
- else
27
- @file_name
28
- end
21
+ @file_name||='CustomLogger.html'
29
22
  end
30
23
 
31
24
  def title=(value)
@@ -33,11 +26,7 @@ module CustomLogger
33
26
  end
34
27
 
35
28
  def title
36
- if @title.nil?
37
- 'Custome Logger'
38
- else
39
- @title
40
- end
29
+ @title||='Custome Logger'
41
30
  end
42
31
 
43
32
  def error_color(state, color)
@@ -46,8 +35,7 @@ module CustomLogger
46
35
  end
47
36
 
48
37
  def error_colors
49
- set_error_colors if @error_colors.nil?
50
- @error_colors
38
+ @error_colors||=set_error_colors
51
39
  end
52
40
 
53
41
  def new
@@ -144,161 +132,17 @@ module CustomLogger
144
132
  end
145
133
 
146
134
  def to_html(state, message, title)
147
- if state == :raw
148
- if title.nil?
149
- [ '<div class="', state, '"><pre>', message, '</pre><time>',
150
- Time.now, '</time></div>' ].join
151
- else
152
- [ '<div class="', state, '"><header>', title, '</header><pre>',
153
- message, '</pre><time>', Time.now, '</time></div>' ].join
154
- end
155
- else
156
- if title.nil?
157
- [ '<div class="', state, '">', message, '<time>',
158
- Time.now, '</time></div>' ].join
135
+ case state
136
+ when :raw
137
+ HTMLTemplate.raw_to_html(message, title)
159
138
  else
160
- [ '<div class="', state, '"><header>', title, '</header>',
161
- message, '<time>', Time.now, '</time></div>' ].join
162
- end
139
+ HTMLTemplate.log_to_html(state, message, title)
163
140
  end
164
141
  end
165
142
 
166
143
  def html
167
144
  error_colors
168
- <<-HTML
169
- <!DOCTYPE html>
170
- <html>
171
- <head>
172
- <meta charset="UTF-8">
173
- <title>#{@title}</title>
174
- <style>
175
- .error {
176
- font-family: monospace, monospace, serif;
177
- font-size: 0.9em;
178
- color: #{@error_colors[:error]};
179
- background-color: #f2dede;
180
- border-color: #8b0000;
181
- padding: 8px;
182
- border: 1px solid darkred;
183
- border-radius: 4px;
184
- margin-bottom: 4px;
185
- }
186
- .error header {
187
- font-size: 1.2em;;
188
- font-weight: bold;
189
- padding-bottom: 4px;
190
- }
191
- .error summary { padding-left: 8px; }
192
- .error time {
193
- font-family: monospace, monospace, serif;
194
- font-size: 0.68em;
195
- display: block;
196
- padding-top: 8px;
197
- }
198
-
199
- .warning {
200
- font-family: monospace, monospace, serif;
201
- font-size: 0.9em;
202
- color: #{@error_colors[:warning]};
203
- background-color: #fcf8e3;
204
- border-color: #faebcc;
205
- padding: 8px;
206
- border: 1px solid #faebcc;
207
- border-radius: 4px;
208
- margin-bottom: 4px;
209
- }
210
- .warning header {
211
- font-size: 1.2em;;
212
- font-weight: bold;
213
- padding-bottom: 4px;
214
- }
215
- .warning summary { padding-left: 8px; }
216
- .warning time {
217
- font-family: monospace, monospace, serif;
218
- font-size: 0.68em;
219
- display: block;
220
- padding-top: 8px;
221
- }
222
-
223
- .debug {
224
- font-family: monospace, monospace, serif;
225
- font-size: 0.9em;
226
- color: #{@error_colors[:debug]};
227
- background-color: #eafbe2;
228
- border-color: #bbcbad;
229
- padding: 8px;
230
- border: 1px solid #bbcbad;
231
- border-radius: 4px;
232
- margin-bottom: 4px;
233
- }
234
- .debug header {
235
- font-size: 1.2em;;
236
- font-weight: bold;
237
- padding-bottom: 4px;
238
- }
239
- .debug summary { padding-left: 8px; }
240
- .debug time {
241
- font-family: monospace, monospace, serif;
242
- font-size: 0.68em;
243
- display: block;
244
- padding-top: 8px;
245
- }
246
-
247
- .info {
248
- font-family: monospace, monospace, serif;
249
- font-size: 0.9em;
250
- color: #{@error_colors[:info]};
251
- background-color: #e0f5ff;
252
- border-color: #a6ccd4;
253
- padding: 8px;
254
- border: 1px solid #a6ccd4;
255
- border-radius: 4px;
256
- margin-bottom: 4px;
257
- }
258
- .info header {
259
- font-size: 1.2em;;
260
- font-weight: bold;
261
- padding-bottom: 4px;
262
- }
263
- .info summary { padding-left: 8px; }
264
- .info time {
265
- font-family: monospace, monospace, serif;
266
- font-size: 0.68em;
267
- display: block;
268
- padding-top: 8px;
269
- }
270
-
271
- .raw {
272
- font-family: monospace, monospace, serif;
273
- font-size: 0.9em;
274
- color: #303030;
275
- background-color: #dcdcdc;
276
- border-color: #a0a0a0;
277
- padding: 8px;
278
- border: 1px solid #a0a0a0;
279
- border-radius: 4px;
280
- margin-bottom: 4px;
281
- }
282
- .raw header {
283
- font-size: 1.2em;;
284
- font-weight: bold;
285
- padding-bottom: 4px;
286
- }
287
- .raw pre { padding-left: 8px; }
288
- .raw time {
289
- font-family: monospace, monospace, serif;
290
- font-size: 0.68em;
291
- display: block;
292
- padding-top: 8px;
293
- }
294
-
295
- section { padding: 28px; }
296
- </style>
297
- </head>
298
- <body>
299
- <h2>Custome Logger</h2>
300
- </body></html>
301
- HTML
145
+ HTMLTemplate.html(@title, @error_colors)
302
146
  end
303
147
 
304
148
  end
@@ -0,0 +1,160 @@
1
+ class HTMLTemplate
2
+ class << self
3
+ def html(title, error_colors)
4
+ <<-HTML
5
+ <!DOCTYPE html>
6
+ <html>
7
+ <head>
8
+ <meta charset="UTF-8">
9
+ <title>#{title}</title>
10
+ <style>
11
+ .error {
12
+ font-family: monospace, monospace, serif;
13
+ font-size: 0.9em;
14
+ color: #{error_colors[:error]};
15
+ background-color: #f2dede;
16
+ border-color: #8b0000;
17
+ padding: 8px;
18
+ border: 1px solid darkred;
19
+ border-radius: 4px;
20
+ margin-bottom: 4px;
21
+ }
22
+ .error header {
23
+ font-size: 1.2em;;
24
+ font-weight: bold;
25
+ padding-bottom: 4px;
26
+ }
27
+ .error summary { padding-left: 8px; }
28
+ .error time {
29
+ font-family: monospace, monospace, serif;
30
+ font-size: 0.68em;
31
+ display: block;
32
+ padding-top: 8px;
33
+ }
34
+
35
+ .warning {
36
+ font-family: monospace, monospace, serif;
37
+ font-size: 0.9em;
38
+ color: #{error_colors[:warning]};
39
+ background-color: #fcf8e3;
40
+ border-color: #faebcc;
41
+ padding: 8px;
42
+ border: 1px solid #faebcc;
43
+ border-radius: 4px;
44
+ margin-bottom: 4px;
45
+ }
46
+ .warning header {
47
+ font-size: 1.2em;;
48
+ font-weight: bold;
49
+ padding-bottom: 4px;
50
+ }
51
+ .warning summary { padding-left: 8px; }
52
+ .warning time {
53
+ font-family: monospace, monospace, serif;
54
+ font-size: 0.68em;
55
+ display: block;
56
+ padding-top: 8px;
57
+ }
58
+
59
+ .debug {
60
+ font-family: monospace, monospace, serif;
61
+ font-size: 0.9em;
62
+ color: #{error_colors[:debug]};
63
+ background-color: #eafbe2;
64
+ border-color: #bbcbad;
65
+ padding: 8px;
66
+ border: 1px solid #bbcbad;
67
+ border-radius: 4px;
68
+ margin-bottom: 4px;
69
+ }
70
+ .debug header {
71
+ font-size: 1.2em;;
72
+ font-weight: bold;
73
+ padding-bottom: 4px;
74
+ }
75
+ .debug summary { padding-left: 8px; }
76
+ .debug time {
77
+ font-family: monospace, monospace, serif;
78
+ font-size: 0.68em;
79
+ display: block;
80
+ padding-top: 8px;
81
+ }
82
+
83
+ .info {
84
+ font-family: monospace, monospace, serif;
85
+ font-size: 0.9em;
86
+ color: #{error_colors[:info]};
87
+ background-color: #e0f5ff;
88
+ border-color: #a6ccd4;
89
+ padding: 8px;
90
+ border: 1px solid #a6ccd4;
91
+ border-radius: 4px;
92
+ margin-bottom: 4px;
93
+ }
94
+ .info header {
95
+ font-size: 1.2em;;
96
+ font-weight: bold;
97
+ padding-bottom: 4px;
98
+ }
99
+ .info summary { padding-left: 8px; }
100
+ .info time {
101
+ font-family: monospace, monospace, serif;
102
+ font-size: 0.68em;
103
+ display: block;
104
+ padding-top: 8px;
105
+ }
106
+
107
+ .raw {
108
+ font-family: monospace, monospace, serif;
109
+ font-size: 0.9em;
110
+ color: #303030;
111
+ background-color: #dcdcdc;
112
+ border-color: #a0a0a0;
113
+ padding: 8px;
114
+ border: 1px solid #a0a0a0;
115
+ border-radius: 4px;
116
+ margin-bottom: 4px;
117
+ }
118
+ .raw header {
119
+ font-size: 1.2em;;
120
+ font-weight: bold;
121
+ padding-bottom: 4px;
122
+ }
123
+ .raw pre { padding-left: 8px; }
124
+ .raw time {
125
+ font-family: monospace, monospace, serif;
126
+ font-size: 0.68em;
127
+ display: block;
128
+ padding-top: 8px;
129
+ }
130
+
131
+ section { padding: 28px; }
132
+ </style>
133
+ </head>
134
+ <body>
135
+ <h2>Custome Logger</h2>
136
+ </body></html>
137
+ HTML
138
+ end
139
+
140
+ def raw_to_html(message, title)
141
+ if title.nil?
142
+ [ '<div class="raw"><pre>', message, '</pre><time>', Time.now,
143
+ '</time></div>' ].join
144
+ else
145
+ [ '<div class="raw"><header>', title, '</header><pre>', message,
146
+ '</pre><time>', Time.now, '</time></div>' ].join
147
+ end
148
+ end
149
+
150
+ def log_to_html(state, message, title)
151
+ if title.nil?
152
+ [ '<div class="', state, '">', message, '<time>',
153
+ Time.now, '</time></div>' ].join
154
+ else
155
+ [ '<div class="', state, '"><header>', title, '</header>',
156
+ message, '<time>', Time.now, '</time></div>' ].join
157
+ end
158
+ end
159
+ end
160
+ end
@@ -1,3 +1,3 @@
1
1
  module Customlogger
2
- VERSION = "0.0.1"
2
+ VERSION = '0.0.2'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: customlogger
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Saimon Lovell
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-12-02 00:00:00.000000000 Z
11
+ date: 2014-12-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -55,20 +55,20 @@ dependencies:
55
55
  description: Have you ever wished that you could debug an output to a html nicely
56
56
  colored page? Now you can.
57
57
  email:
58
- - staysynchronize@gmai.com
58
+ - staysynchronize@gmail.com
59
59
  executables: []
60
60
  extensions: []
61
61
  extra_rdoc_files: []
62
62
  files:
63
63
  - ".gitignore"
64
64
  - Gemfile
65
- - Gemfile.lock
66
65
  - LICENSE
67
66
  - LICENSE.txt
68
67
  - README.md
69
68
  - Rakefile
70
69
  - customlogger.gemspec
71
70
  - lib/customlogger.rb
71
+ - lib/customlogger/html_template.rb
72
72
  - lib/customlogger/version.rb
73
73
  - spec/customlogger_spec.rb
74
74
  - spec/spec_helper.rb
data/Gemfile.lock DELETED
@@ -1,31 +0,0 @@
1
- PATH
2
- remote: .
3
- specs:
4
- customlogger (0.0.1)
5
-
6
- GEM
7
- remote: https://rubygems.org/
8
- specs:
9
- diff-lcs (1.2.5)
10
- rake (10.4.0)
11
- rspec (3.1.0)
12
- rspec-core (~> 3.1.0)
13
- rspec-expectations (~> 3.1.0)
14
- rspec-mocks (~> 3.1.0)
15
- rspec-core (3.1.7)
16
- rspec-support (~> 3.1.0)
17
- rspec-expectations (3.1.2)
18
- diff-lcs (>= 1.2.0, < 2.0)
19
- rspec-support (~> 3.1.0)
20
- rspec-mocks (3.1.3)
21
- rspec-support (~> 3.1.0)
22
- rspec-support (3.1.2)
23
-
24
- PLATFORMS
25
- ruby
26
-
27
- DEPENDENCIES
28
- bundler (~> 1.7)
29
- customlogger!
30
- rake (~> 10.0)
31
- rspec (~> 3.0)