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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 1b27fc6230688732c1f9213c69b81aba3cc6fe68
4
- data.tar.gz: fe67380cce8ab6d20670bdaf109a0d03d6536116
3
+ metadata.gz: 28737f41115721d1dab40ebbd843b01c79191d5b
4
+ data.tar.gz: a84252622c3f5e983ec2eec1386bc378675d5e0b
5
5
  SHA512:
6
- metadata.gz: 1602dffff9e27c38c3d4ad183514eb67e178f451a57d6850670508e49a9d79fc48a62c09e5e135ad424eef5f9090bb76f413fb05d614cd5517c6b98433af3c3e
7
- data.tar.gz: 3c2564328c4d401dac1b84e380550c209ac0ef1a9942136efc394d9d693b04111b853362eb74f80e9e84a5f9b1f5d9a5a6648e998c925f5f1d1101ebd0b96bfa
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="666" alt="_2016-12-12_0_53_25 2" src="https://cloud.githubusercontent.com/assets/1780339/21081243/a083793c-c005-11e6-8d7b-73308a1cc277.png">
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="666" alt="_2016-12-12_0_53_25" src="https://cloud.githubusercontent.com/assets/1780339/21081244/a0bb1892-c005-11e6-81ef-dcf4c153400a.png">
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
- _Rescue error, just log it `Rails.logger.error e` ._
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 displayed log by passing a hash to constructor of `Beautiful::Log::Formatter`.
114
+ You can customize the log appearance by passing a hash to constructor of `Beautiful::Log::Formatter`.
114
115
 
115
- Below is default value.
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
- severity_styles: {}
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, whch is written in `.bundle/config` .
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 the string (color, bold, underline, etc). The elements of the array are applied in order.
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.cyan}\n#{numbered_code_lines(problem_point)}\n"
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 'colorize'
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)
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
  module Beautiful
3
3
  module Log
4
- VERSION = '0.1.2'.freeze
4
+ VERSION = '0.1.4'.freeze
5
5
  end
6
6
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: beautiful-log
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.1.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - nogahighland