rawk_log 2.2.0 → 2.2.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.
data/lib/rawk_log/stat.rb CHANGED
@@ -2,6 +2,8 @@ module RawkLog
2
2
 
3
3
  class Stat
4
4
 
5
+ DEFAULT_LABEL_SIZE = 30
6
+
5
7
  HEADER = "Count Sum Max Median Avg Min Std"
6
8
  HEADER_NEW_LOG_FORMAT = "Count Sum(s) Max Median Avg Min Std"
7
9
 
@@ -28,7 +30,7 @@ module RawkLog
28
30
  @values << value
29
31
  end
30
32
 
31
- def header(label_size = 55)
33
+ def header(label_size = DEFAULT_LABEL_SIZE)
32
34
  header = @new_log_format ? HEADER_NEW_LOG_FORMAT : HEADER
33
35
  sprintf "%*s %s" % [-label_size, "Request", header]
34
36
  end
@@ -71,7 +73,7 @@ module RawkLog
71
73
  Math.sqrt((@sum_squares - (@sum*@sum/@count))/ (@count) )
72
74
  end
73
75
 
74
- def to_s(label_size = 55)
76
+ def to_s(label_size = DEFAULT_LABEL_SIZE)
75
77
  if count > 0
76
78
  if @new_log_format
77
79
  sprintf("%*s %6d %7.2f %7d %7d %7d %7d %7d",-label_size, key,count,(sum.to_f/1000),max,median,average,min,standard_deviation)
@@ -2,6 +2,7 @@ require 'rawk_log/stat'
2
2
 
3
3
  module RawkLog
4
4
  class StatHash
5
+
5
6
  def initialize
6
7
  @stats = Hash.new
7
8
  end
@@ -17,7 +18,7 @@ module RawkLog
17
18
 
18
19
  def print(args={:sort_by=>'key',:ascending=>true,:limit=>nil})
19
20
  values = @stats.values
20
- return 20 if values.empty?
21
+ return Stat::DEFAULT_LABEL_SIZE if values.empty?
21
22
  order = (args[:ascending] || args[:ascending].nil?) ? 1 : -1
22
23
  values.sort! {|a,b|
23
24
  as = a.send(args[:sort_by])
@@ -30,6 +31,7 @@ module RawkLog
30
31
  values = values[0,limit]
31
32
  end
32
33
  @label_size = values.collect{|v| v.key.size }.max
34
+ @label_size = Stat::DEFAULT_LABEL_SIZE if @label_size < Stat::DEFAULT_LABEL_SIZE
33
35
  puts values[0].header(@label_size)
34
36
  for stat in values
35
37
  puts stat.to_s(@label_size)
@@ -1,3 +1,3 @@
1
1
  module RawkLog
2
- VERSION = "2.2.0"
2
+ VERSION = "2.2.1"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rawk_log
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.2.0
4
+ version: 2.2.1
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors: