rawk_log 2.2.1 → 2.2.2
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/command.rb +6 -1
- data/lib/rawk_log/stat.rb +4 -4
- data/lib/rawk_log/version.rb +1 -1
- data/test/examples/rails23.log +1 -1
- data/test/rails23_test.rb +8 -0
- metadata +1 -1
data/lib/rawk_log/command.rb
CHANGED
@@ -79,7 +79,11 @@ module RawkLog
|
|
79
79
|
end
|
80
80
|
|
81
81
|
def is_id?(word)
|
82
|
-
word =~ /^((\d+)|([\dA-F\-]{36}))$/i
|
82
|
+
word =~ /^((\d+(-.*)?)|([\dA-F\-]{36}))$/i
|
83
|
+
end
|
84
|
+
|
85
|
+
def is_filename?(word)
|
86
|
+
word =~ /\.[a-z]{1,5}\d?$/i
|
83
87
|
end
|
84
88
|
|
85
89
|
def build_stats
|
@@ -153,6 +157,7 @@ module RawkLog
|
|
153
157
|
end
|
154
158
|
keywords
|
155
159
|
end
|
160
|
+
keywords[-1] = '{filename}' if ! keywords.empty? and is_filename?(keywords[-1])
|
156
161
|
k = "/#{keywords.join("/")}"
|
157
162
|
end
|
158
163
|
end
|
data/lib/rawk_log/stat.rb
CHANGED
@@ -4,8 +4,8 @@ module RawkLog
|
|
4
4
|
|
5
5
|
DEFAULT_LABEL_SIZE = 30
|
6
6
|
|
7
|
-
HEADER = "Count
|
8
|
-
HEADER_NEW_LOG_FORMAT = "Count
|
7
|
+
HEADER = "Count Sum Max Median Avg Min Std"
|
8
|
+
HEADER_NEW_LOG_FORMAT = "Count Sum(s) Max Median Avg Min Std"
|
9
9
|
|
10
10
|
def initialize(key)
|
11
11
|
@key=key
|
@@ -76,9 +76,9 @@ module RawkLog
|
|
76
76
|
def to_s(label_size = DEFAULT_LABEL_SIZE)
|
77
77
|
if count > 0
|
78
78
|
if @new_log_format
|
79
|
-
sprintf("%*s %6d %
|
79
|
+
sprintf("%*s %6d %9.2f %7d %7d %7d %7d %7d",-label_size, key,count,(sum.to_f/1000),max,median,average,min,standard_deviation)
|
80
80
|
else
|
81
|
-
sprintf("%*s %6d %
|
81
|
+
sprintf("%*s %6d %9.2f %7.2f %7.2f %7.2f %7.2f %7.2f",-label_size,key,count,sum,max,median,average,min,standard_deviation)
|
82
82
|
end
|
83
83
|
else
|
84
84
|
sprintf("%*s %6d",-label_size,key,0)
|
data/lib/rawk_log/version.rb
CHANGED
data/test/examples/rails23.log
CHANGED
@@ -26,5 +26,5 @@ Rendering items/index
|
|
26
26
|
Completed in 5ms (View: 2, DB: 0) | 200 OK [http://0.0.0.0/items]
|
27
27
|
|
28
28
|
Processing DocumentController#download (for 12.13.14.15 at 2012-12-13 11:49:03) [GET]
|
29
|
-
Completed in 936ms (View: 1, DB: 31) | 200 OK [http://www.example.com/document/download/96164/Form 6 - Occupancy permit-2034-20156
|
29
|
+
Completed in 936ms (View: 1, DB: 31) | 200 OK [http://www.example.com/document/download/96164/Form 6 - Occupancy permit-2034-20156 - Unit 1.docx]
|
30
30
|
|
data/test/rails23_test.rb
CHANGED
@@ -30,6 +30,14 @@ class Rails23Test < Test::Unit::TestCase
|
|
30
30
|
assert_match(/^\/items\s+5\s+0\.06/, @output)
|
31
31
|
end
|
32
32
|
|
33
|
+
def test_recognises_ids_and_filenames
|
34
|
+
assert_match(/^\/document\/download\/{ID}\/{filename}/, @output)
|
35
|
+
end
|
36
|
+
|
37
|
+
def test_sums_entries
|
38
|
+
assert_match(/^\/items\s+5\s+0\.06/, @output)
|
39
|
+
end
|
40
|
+
|
33
41
|
def test_exit_status
|
34
42
|
assert_equal(0, @exit_status)
|
35
43
|
end
|