beautiful-log 0.1.2 → 0.1.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +11 -11
- data/lib/beautiful/log/formatter.rb +2 -2
- data/lib/beautiful/log/modules/stylable.rb +2 -1
- data/lib/beautiful/log/version.rb +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: 28737f41115721d1dab40ebbd843b01c79191d5b
|
4
|
+
data.tar.gz: a84252622c3f5e983ec2eec1386bc378675d5e0b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5e7c5687057707f337fd359fdf391e7b84cfc5bb430ed471c0709deeadfb2ced9097dbd16463b977bf2b43fdff158509f9ea2c86ba18aa2b9b7391fad3e8f04e
|
7
|
+
data.tar.gz: 4cee31b3c15d382ce6f382328ea539c0ab1e7bbadba2409875b093a71d858220e1442c552891a1f5db53fb6adc89230b1c6d9e924c987cba02c3e658f7886d01
|
data/README.md
CHANGED
@@ -34,14 +34,15 @@ Thanks to [awesome-print/awesome_print](https://github.com/awesome-print/awesome
|
|
34
34
|
|
35
35
|
- Hash
|
36
36
|
|
37
|
-
<img width="
|
37
|
+
<img width="691" alt="hash" src="https://cloud.githubusercontent.com/assets/1780339/21100292/a3fec7cc-c0b6-11e6-9800-d711e8b9e829.png">
|
38
38
|
|
39
39
|
- ActiveRecord instance
|
40
40
|
|
41
|
-
<img width="
|
41
|
+
<img width="691" alt="ar" src="https://cloud.githubusercontent.com/assets/1780339/21100291/a3fea602-c0b6-11e6-9ab3-d7bca6455947.png">
|
42
42
|
|
43
|
+
[awesome-print/awesome_print](https://github.com/awesome-print/awesome_print) supports [more types](https://github.com/awesome-print/awesome_print/tree/master/lib/awesome_print/formatters) to beautiflize.
|
43
44
|
|
44
|
-
|
45
|
+
_All you need to do is rescue error, just log it `Rails.logger.error e` ._
|
45
46
|
|
46
47
|
## Logs in Rake tasks
|
47
48
|
|
@@ -84,7 +85,7 @@ $ gem install beautiful-log
|
|
84
85
|
config.log_level = :debug # set the level you need
|
85
86
|
```
|
86
87
|
|
87
|
-
You can change log level from `:debug` to `:fatal` depending on staging level (develop/production/test).
|
88
|
+
You can change the log level from `:debug` to `:fatal` depending on staging level (develop/production/test).
|
88
89
|
|
89
90
|
- Rakefile
|
90
91
|
|
@@ -110,9 +111,9 @@ You can change log level from `:debug` to `:fatal` depending on staging level (d
|
|
110
111
|
|
111
112
|
## Configurations
|
112
113
|
|
113
|
-
You can customize
|
114
|
+
You can customize the log appearance by passing a hash to constructor of `Beautiful::Log::Formatter`.
|
114
115
|
|
115
|
-
Below is default
|
116
|
+
Below is a hash containing default values.
|
116
117
|
|
117
118
|
```ruby
|
118
119
|
Beautiful::Log::Formatter.new(
|
@@ -121,21 +122,21 @@ Beautiful::Log::Formatter.new(
|
|
121
122
|
highlighted_line_range: 3,
|
122
123
|
highlighted_line_styles: :cyan,
|
123
124
|
backtrace_styles: :light_red,
|
124
|
-
|
125
|
+
error_file_path_styles: :red,
|
126
|
+
severity_styles: { FATAL: [:red, :swap], ERROR: :red, WARN: :light_red },
|
125
127
|
status_code_styles: { (1..3) => [:green, :bold], 'other' => [:red, :bold] },
|
126
|
-
error_file_path_styles: { FATAL: [:red, :swap], ERROR: :red, WARN: :light_red }
|
127
128
|
)
|
128
129
|
```
|
129
130
|
|
130
131
|
### Note
|
131
132
|
|
132
|
-
- `backtrace_ignore_paths` includes bundle path if you use [Bundler](http://bundler.io/). The bundle path is a string `Bundler.bundle_path` returns,
|
133
|
+
- `backtrace_ignore_paths` includes bundle path if you use [Bundler](http://bundler.io/). The bundle path is a string `Bundler.bundle_path` returns, which is written in `.bundle/config` .
|
133
134
|
|
134
135
|
- If you pass a hash as `status_code_styles` or `severity_styles`, those styles are merged with default values shown above.
|
135
136
|
|
136
137
|
#### Style specification
|
137
138
|
|
138
|
-
- For `*_styles` keys, you can set a **Symbol** or an **Array of Symbol** to style
|
139
|
+
- For `*_styles` keys, you can set a **Symbol** or an **Array of Symbol** to style a string (color, bold, underline, etc). The elements of the array are applied in order.
|
139
140
|
|
140
141
|
- Pick your favorite color or style (called 'mode' in [fazibear/colorize](https://github.com/fazibear/colorize/)) below.
|
141
142
|
- [color](https://github.com/fazibear/colorize/blob/master/lib/colorize/class_methods.rb#L61)
|
@@ -153,7 +154,6 @@ Beautiful::Log::Formatter.new(
|
|
153
154
|
|
154
155
|
# TODOs
|
155
156
|
|
156
|
-
- [ ] Replace old images of pretty-printd object
|
157
157
|
- [ ] Specs
|
158
158
|
- [ ] Is is smarter to pass a proc/block to customize log style?
|
159
159
|
|
@@ -77,8 +77,8 @@ module Beautiful
|
|
77
77
|
def highlighted_code(error)
|
78
78
|
problem_point = error.backtrace.find { |backtrace_line| !ignore_path?(backtrace_line) }
|
79
79
|
return unless problem_point.present?
|
80
|
-
file_path = problem_point.split(':')[0]
|
81
|
-
"\t#{file_path
|
80
|
+
file_path = apply_styles(problem_point.split(':')[0], error_file_path_styles)
|
81
|
+
"\t#{file_path}\n#{numbered_code_lines(problem_point)}\n"
|
82
82
|
end
|
83
83
|
end
|
84
84
|
end
|
@@ -1,5 +1,5 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
|
-
require '
|
2
|
+
require 'colorized_string'
|
3
3
|
|
4
4
|
module Beautiful
|
5
5
|
module Log
|
@@ -8,6 +8,7 @@ module Beautiful
|
|
8
8
|
private
|
9
9
|
|
10
10
|
def apply_styles(string, styles)
|
11
|
+
string = ColorizedString.new(string)
|
11
12
|
styles = [styles] if styles.is_a?(Symbol)
|
12
13
|
styles.each do |style|
|
13
14
|
style = style.to_sym if style.is_a?(String)
|