log-analyzer 0.3.0 → 0.4.0

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: e5a384366b1d5db2d56e84cd9da5f5f03ba27543
4
- data.tar.gz: b71bec30b86641038690a2032d23417952e9659b
3
+ metadata.gz: 866eefaeda010bc822f01b13b9e4d15bf2b7cfbe
4
+ data.tar.gz: 5407e578aee2608481dadb66d5e9b4b351d97b4e
5
5
  SHA512:
6
- metadata.gz: 632a21412bff9769262c034fe1c9e4084a1ad9b219d04dd35f6c3692109d06fd0e9eb0c62b85da034206922e026457f8f6a28c49eafb05d3644d18e7994e3c6b
7
- data.tar.gz: 34958a2ba673033b6fc42ad4e2a9cdef9ac31b458afc06d3d4bbd44dd79502cfe15d4d3cc736e5863882a1e4ed613fe8fbff6ea718018abaf978e94abfc5b2c9
6
+ metadata.gz: 784514f2e132c8558990f4076d197cfe76a16183e91b7f769a67a264a7746f2139a1fc262a3bc218c8325579ffa1bba6601654116a4f1a9d1160951dc3699ac9
7
+ data.tar.gz: f97b7d88c249fd621ce9b50f6191c946d8afbd9138d64373fee8c280935f34dca5055b5f3c45673217a0e742dac4656f574908fa9286416f37d082cd252cad08
data/README.md CHANGED
@@ -40,6 +40,7 @@ Usage: log-analyzer [options] <file ...>
40
40
  -h, --help output usage information
41
41
  -V, --version output the version number
42
42
  -r FILE routing format file
43
+ -S, --log-separator VALUE log separator
43
44
  -R, --route-regexp VALUE route regexp
44
45
  -L, --log-regexp VALUE log regexp
45
46
  ```
@@ -48,11 +49,15 @@ Example:
48
49
 
49
50
  ```shell
50
51
  $ log-analyzer -r path/to/routes.txt path/to/application.log
51
- ┏━━━━━━━━┳━━━━━━━━━━┳━━━━━━━┓
52
- ┃ method ┃ endpoint ┃ count ┃
53
- ┣━━━━━━━━╊━━━━━━━━━━╊━━━━━━━┫
54
- ┃ GET ┃ / 1
55
- ┗━━━━━━━━┻━━━━━━━━━━┻━━━━━━━┛
52
+ ┏━━━━━━━━┳━━━━━━━━━━━━┳━━━━━━━┳━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━┓
53
+ ┃ method ┃ endpoint ┃ count ┃ response_time(avg) ┃ response_time(max) ┃ response_time(min) ┃
54
+ ┣━━━━━━━━╊━━━━━━━━━━━━╊━━━━━━━╊━━━━━━━━━━━━━━━━━━━━╊━━━━━━━━━━━━━━━━━━━━╊━━━━━━━━━━━━━━━━━━━━┫
55
+ ┃ GET ┃ / 10 20.5 ┃ 55 ┃ 3 ┃
56
+ ┃ GET ┃ /users ┃ 5 ┃ 10.3 ┃ 30 ┃ 3 ┃
57
+ ┃ GET ┃ /users/:id ┃ 3 ┃ 10 ┃ 15 ┃ 5 ┃
58
+ ┃ POST ┃ /users ┃ 2 ┃ 30 ┃ 40 ┃ 20 ┃
59
+ ┃ DELETE ┃ /users/:id ┃ 0 ┃ ┃ ┃ ┃
60
+ ┗━━━━━━━━┻━━━━━━━━━━━━┻━━━━━━━┻━━━━━━━━━━━━━━━━━━━━┻━━━━━━━━━━━━━━━━━━━━┻━━━━━━━━━━━━━━━━━━━━┛
56
61
  ```
57
62
 
58
63
  ## Development
@@ -19,6 +19,7 @@ op.on('-V', '--version', 'output the version number') do |v|
19
19
  end
20
20
 
21
21
  op.on('-r FILE', 'routing format file') { |v| opts[:routing_file] = v }
22
+ op.on('-S VALUE', '--log-separator', 'log separator') { |v| opts[:log_separator] = v }
22
23
  op.on('-R VALUE', '--route-regexp', 'route regexp') { |v| opts[:route_regexp] = v }
23
24
  op.on('-L VALUE', '--log-regexp', 'log regexp') { |v| opts[:log_regexp] = v }
24
25
 
@@ -30,6 +31,7 @@ else
30
31
  Log::Analyzer.configure do |config|
31
32
  config.route_regexp = Regexp.new(opts[:route_regexp]) if opts[:route_regexp]
32
33
  config.log_regexp = Regexp.new(opts[:log_regexp]) if opts[:log_regexp]
34
+ config.log_separator = opts[:log_separator] if opts[:log_separator]
33
35
  end
34
36
 
35
37
  Log::Analyzer::CLI.run(ARGV, opts)
@@ -1,10 +1,11 @@
1
1
  module Log::Analyzer
2
2
  class Config
3
- attr_accessor :log_regexp, :route_regexp
3
+ attr_accessor :log_regexp, :route_regexp, :log_separator
4
4
 
5
5
  def initialize
6
6
  @route_regexp = /(GET|POST|DELETE|PATCH|PUT)\s+([^\s]*)\s/i
7
- @log_regexp = /Started (?<request_method>GET|POST|DELETE|PATCH|PUT) "(?<path_info>[^"]+)"/i
7
+ @log_regexp = /Started (?<request_method>GET|POST|DELETE|PATCH|PUT) "(?<path_info>[^"]+)".*in (?<response_time>[0-9]+)ms/im
8
+ @log_separator = "\n\n\n"
8
9
  end
9
10
  end
10
11
  end
@@ -5,7 +5,7 @@ module Log::Analyzer
5
5
  end
6
6
 
7
7
  def each_line(&block)
8
- @file.each_line do |line|
8
+ @file.each_line(separator) do |line|
9
9
  next unless md = line.match(regexp)
10
10
  env = md.names.inject({}) do |hash, name|
11
11
  hash[name.upcase] = md[name]
@@ -19,5 +19,9 @@ module Log::Analyzer
19
19
  def regexp
20
20
  ::Log::Analyzer.config.log_regexp
21
21
  end
22
+
23
+ def separator
24
+ ::Log::Analyzer.config.log_separator
25
+ end
22
26
  end
23
27
  end
@@ -1,5 +1,5 @@
1
1
  module Log
2
2
  module Analyzer
3
- VERSION = "0.3.0"
3
+ VERSION = "0.4.0"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: log-analyzer
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - shiro16
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2016-01-03 00:00:00.000000000 Z
11
+ date: 2016-01-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: actionpack
@@ -175,7 +175,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
175
175
  version: '0'
176
176
  requirements: []
177
177
  rubyforge_project:
178
- rubygems_version: 2.4.5
178
+ rubygems_version: 2.4.5.1
179
179
  signing_key:
180
180
  specification_version: 4
181
181
  summary: Analyze the performance of each endpoint from the routing file