tracee 1.0.4 → 1.0.5

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: 3fe043732447eea6e134cc2693613ee5b60a22fd
4
- data.tar.gz: 7e5c83aa7f1ba6dfb44e363858ade287b8008d5a
3
+ metadata.gz: 629176c76e868df0ce4b840100b9495bbb5e82fe
4
+ data.tar.gz: c462f5a1364a3262ba0cea39cb6515388a766fb6
5
5
  SHA512:
6
- metadata.gz: 0979b18c324e7713e82b1517631bd0ef2fe7dc9bf859b425422911ac22f9b24a36a8bc11e42c0fa22975dbe239c83429820b4b413f5ed1f84238a945be99f2c0
7
- data.tar.gz: 41e0c19b0a631c8f113cfc1e9e0184f488294505c974e3d2bd5334eb7e6deafed7b107844263a2d646c2446c73a2237a6659ea0ed670d3a327443a4d83536ae7
6
+ metadata.gz: b1fca1d6f6a41f110ac635f929171c0cc37763b4f738ae90e0a39f0aa786a926c3beb8c7096566378f99e9725786d3b2756a9c2ff2d976b0e8175a058a7dd7f3
7
+ data.tar.gz: fc1573d63c6634b3ae3fee01c6b976ccf24209bfe4886965ea811a1f6aeb6f1ebab8b43a05c7c43fedc87d3e7411f44a5126ec0b65441a2fe1b8ee17e7ed781a
@@ -17,9 +17,9 @@ module Tracee
17
17
 
18
18
  frames = @error_page.backtrace_frames # original definition
19
19
  frames = frames.map(&:to_s).reject {|line| line =~ IGNORE_RE}
20
- frames = Stack::BaseDecorator.(frames)
20
+ frames = Stack::BaseDecorator.(frames, paint_code_line: :greenish)
21
21
  frames.each do |frame|
22
- if frame =~ /[-\w]+ \(\d+\.[\w\.]+\) /
22
+ if frame =~ /^[-\w]+ \(\d+\.[\w\.]+\) /
23
23
  logger.debug " #{frame}"
24
24
  else
25
25
  logger.fatal " #{frame}"
@@ -0,0 +1,48 @@
1
+ module Tracee::Preprocessors
2
+ class Colorize < Base
3
+ COLOR_MAP = {
4
+ head: :white,
5
+ action: :yellow,
6
+ params: :yellowish,
7
+ redirect: :purple,
8
+ render: :greenish,
9
+ complete: :white,
10
+ raise: :red
11
+ }
12
+
13
+ def initialize(color_map=COLOR_MAP)
14
+ @color_map = color_map
15
+ exception_classes = Exception.descendants
16
+ @exception_classes_re = Exception.descendants.map(&:name).join '|'
17
+ end
18
+
19
+ def call(msg_level, datetime, progname, msg, caller_slice=[])
20
+ case msg
21
+ when %r{^Started (?<method>[A-Z]+) "(?<path>/[^"]*)" for (?<ip>\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}) at (?<time>\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}(?: \+\d{4})?)}
22
+ m = $~
23
+ %{Started #{m[:method].send @color_map[:head]} "#{m[:path].send @color_map[:head]}" for #{m[:ip].send @color_map[:head]} at #{m[:time].send @color_map[:head]}}
24
+ when %r{^Processing by (?<class>[A-Z][\w:]+)#(?<method>\w+) as (?<format>[A-Z]+)$}
25
+ m = $~
26
+ %{Processing by #{m[:class].send @color_map[:action]}##{m[:method].send @color_map[:action]} as #{m[:format].send @color_map[:action]}}
27
+ when %r{^ Parameters: (.+)$}
28
+ m = $~
29
+ " Parameters: #{m[1].send @color_map[:params]}"
30
+ when %r{^Redirected to (\S+)$}
31
+ m = $~
32
+ "Redirected to #{m[1].send @color_map[:redirect]}"
33
+ when %r{^ Rendered .+ \(\d+\.\dms\)$}
34
+ msg.send @color_map[:render]
35
+ when %r{^Completed (?<code>\d{3}) (?<codename>[A-Z][\w ]+) in (?<time>\d+ms) (?<times>.+)$}
36
+ m = $~
37
+ #"\e[4mCompleted #{m[:code].send @color_map[:complete]}\e[4m #{m[:codename].send @color_map[:complete]}\e[4m in #{m[:time].send @color_map[:complete]}\e[4mms #{m[:times]}\e[0m"
38
+ "Completed #{m[:code].send @color_map[:complete]} #{m[:codename].send @color_map[:complete]} in #{m[:time].send @color_map[:complete]} #{m[:times]}"
39
+ when %r{^(BetterErrors::RaisedException|#@exception_classes_re) (.+)}
40
+ m = $~
41
+ "#{m[1].send @color_map[:raise]} #{m[2]}"
42
+ else
43
+ msg
44
+ end
45
+ end
46
+
47
+ end
48
+ end
@@ -3,7 +3,7 @@ module Tracee
3
3
  module BaseDecorator
4
4
 
5
5
  # Make sure that Dir.pwd is the application root directory
6
- def self.call(source)
6
+ def self.call(source, paint_code_line: nil)
7
7
  return source if source.empty? or source[0]["\n"] # already decorated
8
8
 
9
9
  result, current_line_steps = [], []
@@ -21,6 +21,7 @@ module Tracee
21
21
  current_line_steps.unshift "`#{method}#{" {#{step_details[:block_level]}}" if step_details[:block_level]}'"
22
22
  elsif step_details[:line].to_i > 0 and code_line = Tracee::Stack.readline(step_details[:path], step_details[:line].to_i)
23
23
  current_line_steps.unshift step
24
+ code_line = code_line.send paint_code_line if paint_code_line
24
25
  result << "#{current_line_steps * ' -> '}\n >> #{code_line}"
25
26
  current_line_steps = []
26
27
  else
data/lib/tracee/stack.rb CHANGED
@@ -36,7 +36,7 @@ module Tracee
36
36
 
37
37
  def self.readline(file, line)
38
38
  if lines = readlines(file)
39
- (lines[line.to_i - 1] || "<line #{line} is not found> ").chomp.green
39
+ (lines[line.to_i - 1] || "<line #{line} is not found> ").chomp
40
40
  end
41
41
  end
42
42
 
@@ -1,3 +1,3 @@
1
1
  module Tracee
2
- VERSION = "1.0.4"
2
+ VERSION = "1.0.5"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tracee
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.4
4
+ version: 1.0.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sergey Baev
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-04-15 00:00:00.000000000 Z
11
+ date: 2016-04-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -107,6 +107,7 @@ files:
107
107
  - lib/tracee/ext/exception.rb
108
108
  - lib/tracee/logger.rb
109
109
  - lib/tracee/preprocessors/base.rb
110
+ - lib/tracee/preprocessors/colorize.rb
110
111
  - lib/tracee/preprocessors/formatter.rb
111
112
  - lib/tracee/preprocessors/quiet_assets.rb
112
113
  - lib/tracee/stack.rb