customlogger 0.0.1
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 +7 -0
- data/.gitignore +38 -0
- data/Gemfile +3 -0
- data/Gemfile.lock +31 -0
- data/LICENSE +22 -0
- data/LICENSE.txt +22 -0
- data/README.md +74 -0
- data/Rakefile +3 -0
- data/customlogger.gemspec +24 -0
- data/lib/customlogger/version.rb +3 -0
- data/lib/customlogger.rb +305 -0
- data/spec/customlogger_spec.rb +222 -0
- data/spec/spec_helper.rb +11 -0
- data/tasks/rspec.rake +3 -0
- metadata +102 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: c18befff62ddf22661d0d0f258aebe52cf1870c8
|
4
|
+
data.tar.gz: a89f2f5fb94e980158e4944a63a492b4da0a95f4
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: a6e041407899643e38debdd1ed694290eaa27491b0340d768574e5e843111d6a6da3ac015c3111beef8aa72e6300337e5c3eefc5770735eb141a1f379d92d0a1
|
7
|
+
data.tar.gz: 197741d996981c4db83b5fd61dd130840520706f3974d7919dfa3b249b0f773d8f4a6ce6ed997377dd4fa5939e7ca4e3268a8041b4ac5421c749aa8b89b50546
|
data/.gitignore
ADDED
@@ -0,0 +1,38 @@
|
|
1
|
+
*.rbc
|
2
|
+
capybara-*.html
|
3
|
+
.rspec
|
4
|
+
/log
|
5
|
+
/tmp
|
6
|
+
/db/*.sqlite3
|
7
|
+
/public/system
|
8
|
+
/coverage/
|
9
|
+
/spec/tmp
|
10
|
+
**.orig
|
11
|
+
rerun.txt
|
12
|
+
pickle-email-*.html
|
13
|
+
pkg/*
|
14
|
+
|
15
|
+
# TODO Comment out these rules if you are OK with secrets being uploaded to the repo
|
16
|
+
config/initializers/secret_token.rb
|
17
|
+
config/secrets.yml
|
18
|
+
|
19
|
+
## Environment normalisation:
|
20
|
+
/.bundle
|
21
|
+
/vendor/bundle
|
22
|
+
|
23
|
+
# these should all be checked in to normalise the environment:
|
24
|
+
# Gemfile.lock, .ruby-version, .ruby-gemset
|
25
|
+
|
26
|
+
# unless supporting rvm < 1.11.0 or doing something fancy, ignore this:
|
27
|
+
.rvmrc
|
28
|
+
|
29
|
+
# if using bower-rails ignore default bower_components path bower.json files
|
30
|
+
/vendor/assets/bower_components
|
31
|
+
*.bowerrc
|
32
|
+
bower.json
|
33
|
+
|
34
|
+
# Ruby Mine
|
35
|
+
.idea
|
36
|
+
|
37
|
+
# RBenv
|
38
|
+
.ruby-version
|
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,31 @@
|
|
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)
|
data/LICENSE
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2014
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
13
|
+
copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
21
|
+
SOFTWARE.
|
22
|
+
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2014 Saimon Lovell
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,74 @@
|
|
1
|
+
# Custom Logger 1.0.0
|
2
|
+
|
3
|
+
Custom logger allows you to log you're debug infmration to an html file so you can
|
4
|
+
view them in much more easier way. This is my first gem so expect things not
|
5
|
+
to be perfect.
|
6
|
+
|
7
|
+
## Installation
|
8
|
+
|
9
|
+
Add this line to your application's Gemfile:
|
10
|
+
|
11
|
+
```ruby
|
12
|
+
gem 'customlogger'
|
13
|
+
```
|
14
|
+
|
15
|
+
And then execute:
|
16
|
+
|
17
|
+
$ bundle
|
18
|
+
|
19
|
+
Or install it yourself as:
|
20
|
+
|
21
|
+
$ gem install customlogger
|
22
|
+
|
23
|
+
## Usage
|
24
|
+
|
25
|
+
Custom Logger is very easy to use.
|
26
|
+
|
27
|
+
#### Log error
|
28
|
+
|
29
|
+
CustomLogger.error 'This is an error message'
|
30
|
+
CustomLogger.error = 'This is an error message'
|
31
|
+
CustomLogger.error 'This is an error message', 'Error Title'
|
32
|
+
|
33
|
+
#### Log warning
|
34
|
+
|
35
|
+
CustomLogger.warning 'This is an warning message'
|
36
|
+
CustomLogger.warning = 'This is an warning message'
|
37
|
+
CustomLogger.warning 'This is an warning message', 'Warning Title'
|
38
|
+
|
39
|
+
#### Log debug
|
40
|
+
|
41
|
+
CustomLogger.debug 'This is an debug message'
|
42
|
+
CustomLogger.debug = 'This is an debug message'
|
43
|
+
CustomLogger.debug 'This is an debug message', 'Debug Title'
|
44
|
+
|
45
|
+
#### Log info
|
46
|
+
|
47
|
+
CustomLogger.info 'This is an info message'
|
48
|
+
CustomLogger.info = 'This is an info message'
|
49
|
+
CustomLogger.info 'This is an info message', 'Info Title'
|
50
|
+
|
51
|
+
#### Log raw
|
52
|
+
|
53
|
+
CustomLogger.raw 'This is an raw message'
|
54
|
+
CustomLogger.raw = 'This is an raw message'
|
55
|
+
CustomLogger.raw 'This is an raw message', 'Raw Title'
|
56
|
+
|
57
|
+
#### Clear All Logs
|
58
|
+
|
59
|
+
customlogger.clear
|
60
|
+
|
61
|
+
|
62
|
+
## Log File
|
63
|
+
|
64
|
+
You will find the log file in:
|
65
|
+
|
66
|
+
log/customlogger.html
|
67
|
+
|
68
|
+
## Contributing
|
69
|
+
|
70
|
+
1. Fork it ( https://github.com/[my-github-username]/customlogger/fork )
|
71
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
72
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
73
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
74
|
+
5. Create a new Pull Request
|
data/Rakefile
ADDED
@@ -0,0 +1,24 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'customlogger/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "customlogger"
|
8
|
+
spec.version = Customlogger::VERSION
|
9
|
+
spec.authors = ["Saimon Lovell"]
|
10
|
+
spec.email = ["staysynchronize@gmai.com"]
|
11
|
+
spec.summary = %q{Log output in to a seperate html file.}
|
12
|
+
spec.description = %q{Have you ever wished that you could debug an output to a html nicely colored page? Now you can.}
|
13
|
+
spec.homepage = "https://github.com/SaimonL/CustomLogger"
|
14
|
+
spec.license = "MIT"
|
15
|
+
|
16
|
+
spec.files = `git ls-files -z`.split("\x0")
|
17
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
|
+
spec.require_paths = ["lib"]
|
20
|
+
|
21
|
+
spec.add_development_dependency "bundler", "~> 1.7"
|
22
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
23
|
+
spec.add_development_dependency 'rspec', '~> 3.0'
|
24
|
+
end
|
data/lib/customlogger.rb
ADDED
@@ -0,0 +1,305 @@
|
|
1
|
+
require "customlogger/version"
|
2
|
+
|
3
|
+
module CustomLogger
|
4
|
+
LOOP_LIMIT = 512
|
5
|
+
|
6
|
+
class << self
|
7
|
+
def path=(value)
|
8
|
+
@log_path = value
|
9
|
+
end
|
10
|
+
|
11
|
+
def path
|
12
|
+
if @log_path.nil?
|
13
|
+
[ Dir.pwd, '/log' ].join
|
14
|
+
else
|
15
|
+
@log_path
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
def file=(value)
|
20
|
+
@file_name = value
|
21
|
+
end
|
22
|
+
|
23
|
+
def file
|
24
|
+
if @file_name.nil?
|
25
|
+
'CustomLogger.html'
|
26
|
+
else
|
27
|
+
@file_name
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
def title=(value)
|
32
|
+
@title = value
|
33
|
+
end
|
34
|
+
|
35
|
+
def title
|
36
|
+
if @title.nil?
|
37
|
+
'Custome Logger'
|
38
|
+
else
|
39
|
+
@title
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
def error_color(state, color)
|
44
|
+
set_error_colors if @error_colors.nil?
|
45
|
+
@error_colors[state] = color
|
46
|
+
end
|
47
|
+
|
48
|
+
def error_colors
|
49
|
+
set_error_colors if @error_colors.nil?
|
50
|
+
@error_colors
|
51
|
+
end
|
52
|
+
|
53
|
+
def new
|
54
|
+
new_log_file
|
55
|
+
'Wiped All Old Logs'
|
56
|
+
end
|
57
|
+
|
58
|
+
def clear
|
59
|
+
new_log_file
|
60
|
+
'Wiped All Old Logs'
|
61
|
+
end
|
62
|
+
|
63
|
+
def error=(value)
|
64
|
+
log(:error, value)
|
65
|
+
value
|
66
|
+
end
|
67
|
+
|
68
|
+
def error(value, title=nil)
|
69
|
+
log(:error, value, title)
|
70
|
+
value
|
71
|
+
end
|
72
|
+
|
73
|
+
def warning=(value)
|
74
|
+
log(:warning, value)
|
75
|
+
value
|
76
|
+
end
|
77
|
+
|
78
|
+
def warning(value, title=nil)
|
79
|
+
log(:warning, value, title)
|
80
|
+
value
|
81
|
+
end
|
82
|
+
|
83
|
+
def debug=(value)
|
84
|
+
log(:debug, value)
|
85
|
+
value
|
86
|
+
end
|
87
|
+
|
88
|
+
def debug(value, title=nil)
|
89
|
+
log(:debug, value, title)
|
90
|
+
value
|
91
|
+
end
|
92
|
+
|
93
|
+
def info=(value)
|
94
|
+
log(:info, value)
|
95
|
+
value
|
96
|
+
end
|
97
|
+
|
98
|
+
def info(value, title=nil)
|
99
|
+
log(:info, value, title)
|
100
|
+
value
|
101
|
+
end
|
102
|
+
|
103
|
+
def raw=(value)
|
104
|
+
log(:raw, value)
|
105
|
+
value
|
106
|
+
end
|
107
|
+
|
108
|
+
def raw(value, title=nil)
|
109
|
+
log(:raw, value, title)
|
110
|
+
value
|
111
|
+
end
|
112
|
+
|
113
|
+
private
|
114
|
+
def set_error_colors
|
115
|
+
@error_colors = {
|
116
|
+
error: '#8b0000', warning: '#614c29',
|
117
|
+
debug: '#2d5a2e', info: '#31708f'
|
118
|
+
}
|
119
|
+
end
|
120
|
+
|
121
|
+
def new_log_file
|
122
|
+
file_path_name = [ path, file ].join('/')
|
123
|
+
system "mkdir -p #{path}"
|
124
|
+
File.open(file_path_name, 'w') { |file| file.write(html) }
|
125
|
+
end
|
126
|
+
|
127
|
+
def log(state, message, title = nil)
|
128
|
+
if @logged_total.nil?
|
129
|
+
@logged_total = 0
|
130
|
+
else
|
131
|
+
abort('Infinite loop possibility!!') if @logged_total > LOOP_LIMIT
|
132
|
+
end
|
133
|
+
|
134
|
+
file_path_name = [ path, file ].join('/')
|
135
|
+
new_log_file unless File.exist?(file_path_name)
|
136
|
+
|
137
|
+
written_logs = File.read(file_path_name)
|
138
|
+
written_logs = written_logs[0..-15].to_s
|
139
|
+
written_logs = written_logs[0...-1] if written_logs[-1] == '<'
|
140
|
+
written_logs.concat(to_html(state, message, title))
|
141
|
+
written_logs.concat('</body></html>')
|
142
|
+
File.open(file_path_name, 'w') { |file| file.write(written_logs) }
|
143
|
+
@logged_total += 1
|
144
|
+
end
|
145
|
+
|
146
|
+
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
|
159
|
+
else
|
160
|
+
[ '<div class="', state, '"><header>', title, '</header>',
|
161
|
+
message, '<time>', Time.now, '</time></div>' ].join
|
162
|
+
end
|
163
|
+
end
|
164
|
+
end
|
165
|
+
|
166
|
+
def html
|
167
|
+
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
|
302
|
+
end
|
303
|
+
|
304
|
+
end
|
305
|
+
end
|
@@ -0,0 +1,222 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe 'with Custom Logger' do
|
4
|
+
|
5
|
+
describe 'with path call' do
|
6
|
+
it 'will return current path if not specified' do
|
7
|
+
expect(CustomLogger.path).to eq [ Dir.pwd, '/log' ].join
|
8
|
+
end
|
9
|
+
|
10
|
+
it 'will return set log_path if was specified' do
|
11
|
+
CustomLogger.path = '/saimon/lovell'
|
12
|
+
expect(CustomLogger.path).to eq '/saimon/lovell'
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
describe 'with file call' do
|
17
|
+
it 'will return current file name if not specified' do
|
18
|
+
expect(CustomLogger.file).to eq 'CustomLogger.html'
|
19
|
+
end
|
20
|
+
|
21
|
+
it 'will return set file name if was specified' do
|
22
|
+
CustomLogger.file = 'saimon.lovell'
|
23
|
+
expect(CustomLogger.file).to eq 'saimon.lovell'
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
describe 'with title call' do
|
28
|
+
it 'will return current title if not specified' do
|
29
|
+
expect(CustomLogger.title).to eq 'Custome Logger'
|
30
|
+
end
|
31
|
+
|
32
|
+
it 'will return set title if was specified' do
|
33
|
+
CustomLogger.title = 'Custome Logger Saimon Lovell'
|
34
|
+
expect(CustomLogger.title).to eq 'Custome Logger Saimon Lovell'
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
describe 'with error colors' do
|
39
|
+
it 'will have default error colors' do
|
40
|
+
expect( CustomLogger.error_colors
|
41
|
+
).to eq ({ error: '#8b0000', warning: '#614c29', debug: '#2d5a2e',
|
42
|
+
info: '#31708f' })
|
43
|
+
end
|
44
|
+
|
45
|
+
it 'will allow to set error color' do
|
46
|
+
CustomLogger.error_color(:error, 'lovell')
|
47
|
+
expect( CustomLogger.error_colors
|
48
|
+
).to eq ({ error: 'lovell', warning: '#614c29', debug: '#2d5a2e',
|
49
|
+
info: '#31708f' })
|
50
|
+
end
|
51
|
+
|
52
|
+
it 'will allow to set warning color' do
|
53
|
+
CustomLogger.error_color(:warning, 'slovell')
|
54
|
+
expect( CustomLogger.error_colors
|
55
|
+
).to eq ({ error: 'lovell', warning: 'slovell', debug: '#2d5a2e',
|
56
|
+
info: '#31708f' })
|
57
|
+
end
|
58
|
+
|
59
|
+
it 'will allow to set debug color' do
|
60
|
+
CustomLogger.error_color(:debug, 'saimon')
|
61
|
+
expect( CustomLogger.error_colors
|
62
|
+
|
63
|
+
).to eq ({ error: 'lovell', warning: 'slovell', debug: 'saimon',
|
64
|
+
info: '#31708f' })
|
65
|
+
end
|
66
|
+
|
67
|
+
it 'will allow to set debug color' do
|
68
|
+
CustomLogger.error_color(:info, 'ssl')
|
69
|
+
expect( CustomLogger.error_colors
|
70
|
+
|
71
|
+
).to eq ({ error: 'lovell', warning: 'slovell', debug: 'saimon',
|
72
|
+
info: 'ssl' })
|
73
|
+
end
|
74
|
+
end
|
75
|
+
|
76
|
+
describe 'with logging message' do
|
77
|
+
before(:each) do
|
78
|
+
allow(CustomLogger).to receive(:log).and_return(true)
|
79
|
+
end
|
80
|
+
|
81
|
+
describe 'with title' do
|
82
|
+
it 'will return logged error' do
|
83
|
+
expect(CustomLogger.error('ss saimon', 'my title')).to eq 'ss saimon'
|
84
|
+
end
|
85
|
+
|
86
|
+
it 'will return logged warning' do
|
87
|
+
expect(CustomLogger.warning('ss saimon 123', 'my title')).to eq 'ss saimon 123'
|
88
|
+
end
|
89
|
+
|
90
|
+
it 'will return logged info' do
|
91
|
+
expect(CustomLogger.info('ss saimon 123 abc', 'my title')).to eq 'ss saimon 123 abc'
|
92
|
+
end
|
93
|
+
|
94
|
+
it 'will return logged raw' do
|
95
|
+
expect(CustomLogger.raw('saimon 123 abc', 'my title')).to eq 'saimon 123 abc'
|
96
|
+
end
|
97
|
+
end
|
98
|
+
|
99
|
+
describe 'without title' do
|
100
|
+
it 'will return logged error' do
|
101
|
+
expect(CustomLogger.error = 'ss saimon').to eq 'ss saimon'
|
102
|
+
end
|
103
|
+
|
104
|
+
it 'will return logged warning' do
|
105
|
+
expect(CustomLogger.warning = 'ss saimon 123').to eq 'ss saimon 123'
|
106
|
+
end
|
107
|
+
|
108
|
+
it 'will return logged info' do
|
109
|
+
expect(CustomLogger.info = 'ss saimon 123 abc').to eq 'ss saimon 123 abc'
|
110
|
+
end
|
111
|
+
|
112
|
+
it 'will return logged raw' do
|
113
|
+
expect(CustomLogger.raw = 'saimon 123 abc').to eq 'saimon 123 abc'
|
114
|
+
end
|
115
|
+
end
|
116
|
+
end
|
117
|
+
|
118
|
+
describe 'with loggin error file' do
|
119
|
+
before(:all) do
|
120
|
+
CustomLogger.path = Dir.pwd
|
121
|
+
CustomLogger.file = 'delete-me.html'
|
122
|
+
@file_location = [ CustomLogger.path, CustomLogger.file ].join '/'
|
123
|
+
end
|
124
|
+
|
125
|
+
after(:all) { File.delete [ CustomLogger.path, CustomLogger.file ].join '/' }
|
126
|
+
|
127
|
+
describe 'with error loggin' do
|
128
|
+
before(:all) do
|
129
|
+
CustomLogger.error('this is an error', 'hello')
|
130
|
+
@data = read_file(@file_location)
|
131
|
+
end
|
132
|
+
|
133
|
+
it 'will add error message to the html file' do
|
134
|
+
expect(@data).to include 'this is an error'
|
135
|
+
end
|
136
|
+
|
137
|
+
it 'will add error title to the html file' do
|
138
|
+
expect(@data).to include '<header>hello</header>'
|
139
|
+
end
|
140
|
+
end
|
141
|
+
|
142
|
+
describe 'with warning loggin' do
|
143
|
+
before(:all) do
|
144
|
+
CustomLogger.warning('this is an warning', 'hi there')
|
145
|
+
@data = read_file(@file_location)
|
146
|
+
end
|
147
|
+
|
148
|
+
it 'will add error message to the html file' do
|
149
|
+
expect(@data).to include 'this is an warning'
|
150
|
+
end
|
151
|
+
|
152
|
+
it 'will add error title to the html file' do
|
153
|
+
expect(@data).to include '<header>hi there</header>'
|
154
|
+
end
|
155
|
+
end
|
156
|
+
|
157
|
+
describe 'with debug loggin' do
|
158
|
+
before(:all) do
|
159
|
+
CustomLogger.debug('this is an debug', 'hi you')
|
160
|
+
@data = read_file(@file_location)
|
161
|
+
end
|
162
|
+
|
163
|
+
it 'will add error message to the html file' do
|
164
|
+
expect(@data).to include 'this is an debug'
|
165
|
+
end
|
166
|
+
|
167
|
+
it 'will add error title to the html file' do
|
168
|
+
expect(@data).to include '<header>hi you</header>'
|
169
|
+
end
|
170
|
+
end
|
171
|
+
|
172
|
+
describe 'with info loggin' do
|
173
|
+
before(:all) do
|
174
|
+
CustomLogger.info('this is an info', 'hello you')
|
175
|
+
@data = read_file(@file_location)
|
176
|
+
end
|
177
|
+
|
178
|
+
it 'will add error message to the html file' do
|
179
|
+
expect(@data).to include 'this is an info'
|
180
|
+
end
|
181
|
+
|
182
|
+
it 'will add error title to the html file' do
|
183
|
+
expect(@data).to include '<header>hello you</header>'
|
184
|
+
end
|
185
|
+
end
|
186
|
+
|
187
|
+
describe 'with raw loggin' do
|
188
|
+
before(:all) do
|
189
|
+
CustomLogger.raw('this is an raw', 'hello abc')
|
190
|
+
@data = read_file(@file_location)
|
191
|
+
end
|
192
|
+
|
193
|
+
it 'will add error message to the html file' do
|
194
|
+
expect(@data).to include 'this is an raw'
|
195
|
+
end
|
196
|
+
|
197
|
+
it 'will add error title to the html file' do
|
198
|
+
expect(@data).to include '<header>hello abc</header>'
|
199
|
+
end
|
200
|
+
end
|
201
|
+
|
202
|
+
describe 'with cleanup' do
|
203
|
+
before(:all) do
|
204
|
+
CustomLogger.clear
|
205
|
+
@data = read_file(@file_location)
|
206
|
+
end
|
207
|
+
|
208
|
+
it 'will cleanup file log' do
|
209
|
+
expect(@data).to_not include '<header>hello abc</header>'
|
210
|
+
end
|
211
|
+
end
|
212
|
+
|
213
|
+
describe 'with no file' do
|
214
|
+
before(:each) { File.delete([ CustomLogger.path, CustomLogger.file ].join('/')) }
|
215
|
+
|
216
|
+
it 'will be able to create a file on the fly' do
|
217
|
+
expect(CustomLogger.error = 'ss saimon').to eq 'ss saimon'
|
218
|
+
end
|
219
|
+
end
|
220
|
+
end
|
221
|
+
|
222
|
+
end
|
data/spec/spec_helper.rb
ADDED
data/tasks/rspec.rake
ADDED
metadata
ADDED
@@ -0,0 +1,102 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: customlogger
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Saimon Lovell
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2014-12-02 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.7'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.7'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '10.0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '10.0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rspec
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '3.0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '3.0'
|
55
|
+
description: Have you ever wished that you could debug an output to a html nicely
|
56
|
+
colored page? Now you can.
|
57
|
+
email:
|
58
|
+
- staysynchronize@gmai.com
|
59
|
+
executables: []
|
60
|
+
extensions: []
|
61
|
+
extra_rdoc_files: []
|
62
|
+
files:
|
63
|
+
- ".gitignore"
|
64
|
+
- Gemfile
|
65
|
+
- Gemfile.lock
|
66
|
+
- LICENSE
|
67
|
+
- LICENSE.txt
|
68
|
+
- README.md
|
69
|
+
- Rakefile
|
70
|
+
- customlogger.gemspec
|
71
|
+
- lib/customlogger.rb
|
72
|
+
- lib/customlogger/version.rb
|
73
|
+
- spec/customlogger_spec.rb
|
74
|
+
- spec/spec_helper.rb
|
75
|
+
- tasks/rspec.rake
|
76
|
+
homepage: https://github.com/SaimonL/CustomLogger
|
77
|
+
licenses:
|
78
|
+
- MIT
|
79
|
+
metadata: {}
|
80
|
+
post_install_message:
|
81
|
+
rdoc_options: []
|
82
|
+
require_paths:
|
83
|
+
- lib
|
84
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
85
|
+
requirements:
|
86
|
+
- - ">="
|
87
|
+
- !ruby/object:Gem::Version
|
88
|
+
version: '0'
|
89
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
90
|
+
requirements:
|
91
|
+
- - ">="
|
92
|
+
- !ruby/object:Gem::Version
|
93
|
+
version: '0'
|
94
|
+
requirements: []
|
95
|
+
rubyforge_project:
|
96
|
+
rubygems_version: 2.4.4
|
97
|
+
signing_key:
|
98
|
+
specification_version: 4
|
99
|
+
summary: Log output in to a seperate html file.
|
100
|
+
test_files:
|
101
|
+
- spec/customlogger_spec.rb
|
102
|
+
- spec/spec_helper.rb
|