log_analyzer 0.1.4 → 0.1.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/README.md +32 -2
- data/lib/log_analyzer/analyzer.rb +13 -10
- data/lib/log_analyzer/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: bbb66a793c6b6c55af9babe00eba4212980858ab
|
4
|
+
data.tar.gz: 0fe03b724b5727c1b410a88a0276d456e10af800
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 40aedbef25daf98e33b2a3904edf40867c00fd588cd1c73e5d5dc26936e0601fec58afe7c30e202fa128a24aff34639df5e557bbfc2e943b1fad4323a91d67fa
|
7
|
+
data.tar.gz: 3022606d6ed63cbd3482b5eb01daaf32ed4e02239d44d6ecfd1f77b7ba9a5c7eef45ec1e9f3140ee7c7c5c2d5c9311f026aefdef24b790ebb2237bd9933d97b2
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -1,9 +1,24 @@
|
|
1
1
|
# LogAnalyzer
|
2
2
|
|
3
|
-
See how fast is rendering in your app. Based on information from logs
|
3
|
+
See how fast is rendering in your Ruby on Rails app. Based on information from logs. Provides you a picture of how often renders and how fast renders your views.
|
4
|
+
|
5
|
+
## Sample
|
6
|
+
|
7
|
+
[![Sample](https://raw.githubusercontent.com/igorkasyanchuk/log_analyzer/master/docs/log_analyzer.png)](https://raw.githubusercontent.com/igorkasyanchuk/log_analyzer/master/docs/log_analyzer.png)
|
8
|
+
|
9
|
+
You can see columns:
|
10
|
+
|
11
|
+
* View - name of view
|
12
|
+
* Count - number of renders
|
13
|
+
* Avg - average time of rendering (in milliseconds)
|
14
|
+
* Max - maximum number of rendering
|
15
|
+
* Min - minimum number of rendering
|
16
|
+
|
4
17
|
|
5
18
|
## Installation
|
6
19
|
|
20
|
+
Could be installed as standalone (without adding to Gemfile).
|
21
|
+
|
7
22
|
Add this line to your application's Gemfile:
|
8
23
|
|
9
24
|
```ruby
|
@@ -20,7 +35,18 @@ Or install it yourself as:
|
|
20
35
|
|
21
36
|
## Usage
|
22
37
|
|
23
|
-
|
38
|
+
After instalation run in console command `log_analyzer -f log/development.log`. You can change the file or sorting (time, count, name).
|
39
|
+
Samples:
|
40
|
+
|
41
|
+
* `log_analyzer log/development.log -s count`
|
42
|
+
* `log_analyzer log/production.log`
|
43
|
+
* `log_analyzer -f log/production.log -s name`
|
44
|
+
* `log_analyzer -f log/production.log -s time`
|
45
|
+
* `log_analyzer -file log/production.log -sort count`
|
46
|
+
|
47
|
+
**Based on results you can get an idea what to optimize. For example optimizing most often rendering view could give huge benefit. Now with this tool you can find out what are the numbers.**
|
48
|
+
|
49
|
+
Based on the observations I suggest to run this tool for files less than 1Gb. If you have enough RAM - download log file to local machine and then run the tool.
|
24
50
|
|
25
51
|
## Development
|
26
52
|
|
@@ -32,6 +58,10 @@ To install this gem onto your local machine, run `bundle exec rake install`. To
|
|
32
58
|
|
33
59
|
Bug reports and pull requests are welcome on GitHub at https://github.com/varyform/log_analyzer. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
|
34
60
|
|
61
|
+
## TODO
|
62
|
+
|
63
|
+
* more analytics
|
64
|
+
* specs
|
35
65
|
|
36
66
|
## License
|
37
67
|
|
@@ -6,6 +6,7 @@ module LogAnalyzer
|
|
6
6
|
DANGER_DEFAULT = 800 # ms
|
7
7
|
WARNING_DEFAULT = 400 # ms
|
8
8
|
INFO_DEFAULT = 100 # ms
|
9
|
+
HEADER = ['View', 'Count', 'AVG (ms)', 'Max', 'Min'].freeze
|
9
10
|
|
10
11
|
attr_reader :filename
|
11
12
|
attr_reader :stats
|
@@ -40,17 +41,19 @@ module LogAnalyzer
|
|
40
41
|
def visualize(limit: 100)
|
41
42
|
length = (0..DEFAULT_TABLE_WIDTH - 20).freeze
|
42
43
|
table = Terminal::Table.new \
|
43
|
-
headings:
|
44
|
+
headings: HEADER,
|
44
45
|
width: DEFAULT_TABLE_WIDTH do |t|
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
46
|
+
stats.each do |path, stat|
|
47
|
+
t.add_row [
|
48
|
+
path[length],
|
49
|
+
stat.count,
|
50
|
+
avg_label(stat.avg),
|
51
|
+
stat.max,
|
52
|
+
stat.min,
|
53
|
+
]
|
54
|
+
end
|
55
|
+
t.add_separator
|
56
|
+
t.add_row(HEADER)
|
54
57
|
end
|
55
58
|
puts table
|
56
59
|
end
|
data/lib/log_analyzer/version.rb
CHANGED