log_analyzer 0.2.3 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +11 -2
- data/README.md +3 -2
- data/bin/log_analyzer +20 -2
- data/lib/log_analyzer.rb +3 -0
- data/lib/log_analyzer/analyzer.rb +51 -2
- data/lib/log_analyzer/utils.rb +4 -0
- data/lib/log_analyzer/version.rb +1 -1
- data/log_analyzer.gemspec +2 -0
- metadata +30 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c264c821832afb95340f8ca5271b0b1689cc3b6a
|
4
|
+
data.tar.gz: f43cdb0b6233b0176e228e85b497ab282c85f4ae
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 471593211dbb5d4687688a00fbc27e9ce344f6b2c992d460efa66aecf725b6aa993df3ac5f79fe41170beffb9aa915543ce9bdf0aecd30400fd45b1410f66d7e
|
7
|
+
data.tar.gz: 51f4851dc0f8eb1d245f4af434ecb2b4e4c2c9cc4e5a52bbbcad67a0654d5a4cd786db33ad3d95f008bf7bb7f343582424a151d378b109e8884d24b7a76fc529
|
data/Gemfile.lock
CHANGED
@@ -1,8 +1,10 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
log_analyzer (0.
|
4
|
+
log_analyzer (0.3.0)
|
5
5
|
colorize
|
6
|
+
prawn
|
7
|
+
prawn-table
|
6
8
|
rake
|
7
9
|
terminal-table
|
8
10
|
thor
|
@@ -16,6 +18,12 @@ GEM
|
|
16
18
|
docile (1.1.5)
|
17
19
|
json (2.0.3)
|
18
20
|
method_source (0.9.0)
|
21
|
+
pdf-core (0.7.0)
|
22
|
+
prawn (2.2.2)
|
23
|
+
pdf-core (~> 0.7.0)
|
24
|
+
ttfunk (~> 1.5)
|
25
|
+
prawn-table (0.2.2)
|
26
|
+
prawn (>= 1.3.0, < 3.0.0)
|
19
27
|
pry (0.11.3)
|
20
28
|
coderay (~> 1.1.0)
|
21
29
|
method_source (~> 0.9.0)
|
@@ -41,6 +49,7 @@ GEM
|
|
41
49
|
terminal-table (1.8.0)
|
42
50
|
unicode-display_width (~> 1.1, >= 1.1.1)
|
43
51
|
thor (0.20.0)
|
52
|
+
ttfunk (1.5.1)
|
44
53
|
unicode-display_width (1.3.0)
|
45
54
|
|
46
55
|
PLATFORMS
|
@@ -54,4 +63,4 @@ DEPENDENCIES
|
|
54
63
|
simplecov
|
55
64
|
|
56
65
|
BUNDLED WITH
|
57
|
-
1.
|
66
|
+
1.15.3
|
data/README.md
CHANGED
@@ -42,6 +42,8 @@ Samples:
|
|
42
42
|
|
43
43
|
* `log_analyzer log/development.log -s count`
|
44
44
|
* `log_analyzer log/production.log`
|
45
|
+
* `log_analyzer production.log -csv`
|
46
|
+
* `log_analyzer production.log -pdf`
|
45
47
|
* `log_analyzer -f log/production.log -s name`
|
46
48
|
* `log_analyzer -f log/production.log -s time -f v`
|
47
49
|
* `log_analyzer -file log/production.log -sort count`
|
@@ -74,13 +76,12 @@ Big thank you to all our contributors:
|
|
74
76
|
* [@ck3g](https://github.com/ck3g)
|
75
77
|
* [@ritaritual](https://github.com/ritaritual)
|
76
78
|
* [@y-yagi](https://github.com/y-yagi)
|
79
|
+
* [@RafaelHashimoto](https://github.com/RafaelHashimoto)
|
77
80
|
|
78
81
|
## TODO
|
79
82
|
|
80
83
|
* more analytics
|
81
84
|
* more specs
|
82
|
-
* export to PDF
|
83
|
-
* export to CSV
|
84
85
|
* export to XLS
|
85
86
|
* export to HTML/CSS/JS with datatable.js
|
86
87
|
|
data/bin/log_analyzer
CHANGED
@@ -27,6 +27,14 @@ parser = OptionParser.new do |opts|
|
|
27
27
|
options[:short] = v
|
28
28
|
end
|
29
29
|
|
30
|
+
opts.on("-pdf", "--output=pdf", "Export to .pdf") do |v|
|
31
|
+
options[:format] = 'pdf'
|
32
|
+
end
|
33
|
+
|
34
|
+
opts.on('-csv', '--output=csv', 'Export to .csv') do |v|
|
35
|
+
options[:format] = 'csv'
|
36
|
+
end
|
37
|
+
|
30
38
|
opts.on('-h', '--help', 'Displays Help') do
|
31
39
|
puts opts
|
32
40
|
exit
|
@@ -40,22 +48,32 @@ end
|
|
40
48
|
|
41
49
|
parser.parse!
|
42
50
|
|
51
|
+
# Define default params
|
43
52
|
options[:file] = ARGV[0] if ARGV.size == 1 # user first argument as filename
|
44
53
|
options[:sort] ||= :time # default order
|
45
54
|
options[:filter] ||= :all # default order
|
46
55
|
options[:short] ||= false
|
56
|
+
options[:format] ||= 'console'
|
47
57
|
|
48
58
|
LogAnalyzer::Configuration.configure do |config|
|
49
59
|
config.filter = options[:filter]
|
50
60
|
end
|
51
61
|
|
52
|
-
# puts "Running with: #{options.inspect}" # debug
|
62
|
+
# puts "Running with: #{options.inspect}".green # debug
|
53
63
|
|
54
64
|
if options[:file] && options[:sort]
|
55
65
|
analyzer = LogAnalyzer.analyze(filename: options[:file])
|
56
66
|
analyzer.run
|
57
67
|
analyzer.order(by: options[:sort])
|
58
|
-
|
68
|
+
case options[:format]
|
69
|
+
when 'pdf'
|
70
|
+
analyzer.to_pdf(LogAnalyzer::Utils.report_name('pdf'), short: options[:short])
|
71
|
+
when 'csv'
|
72
|
+
analyzer.to_csv(LogAnalyzer::Utils.report_name('csv'), short: options[:short])
|
73
|
+
else
|
74
|
+
analyzer.visualize(short: options[:short])
|
75
|
+
end
|
59
76
|
else
|
60
77
|
parser.parse! %w[--help]
|
61
78
|
end
|
79
|
+
|
data/lib/log_analyzer.rb
CHANGED
@@ -49,7 +49,7 @@ module LogAnalyzer
|
|
49
49
|
stats.each do |path, stat|
|
50
50
|
next unless LogAnalyzer.configuration.filters.include?(stat.type)
|
51
51
|
|
52
|
-
table.add_row
|
52
|
+
table.add_row console_row(path, stat, short)
|
53
53
|
|
54
54
|
rows_count += 1
|
55
55
|
end
|
@@ -63,9 +63,44 @@ module LogAnalyzer
|
|
63
63
|
puts(table)
|
64
64
|
end
|
65
65
|
|
66
|
+
def to_pdf(out_filename, short: false)
|
67
|
+
this = self
|
68
|
+
data = [HEADER]
|
69
|
+
this.stats.each do |path, stat|
|
70
|
+
next unless LogAnalyzer.configuration.filters.include?(stat.type)
|
71
|
+
data << pdf_row(path, stat, short)
|
72
|
+
end
|
73
|
+
Prawn::Document.generate(out_filename) do
|
74
|
+
width = 72
|
75
|
+
text "LogAnalyzer Report", align: :center, size: 18
|
76
|
+
text Time.now.strftime("Generated on %B %d, %Y at %I:%M%p") , align: :center, size: 7
|
77
|
+
move_down 12
|
78
|
+
table data,
|
79
|
+
width: bounds.width,
|
80
|
+
header: true,
|
81
|
+
row_colors: ["FFFFFF", "FFFFCC"],
|
82
|
+
cell_style: { padding: [2, 2, 2, 2], size: 7 } do |t|
|
83
|
+
t.columns(0).style(align: :center)
|
84
|
+
end
|
85
|
+
move_down 20
|
86
|
+
text %(Generated by <link href="https://github.com/igorkasyanchuk/log_analyzer">https://github.com/igorkasyanchuk/log_analyzer</link>.), inline_format: true, size: 5, color: 'CCCCCC'
|
87
|
+
end
|
88
|
+
end
|
89
|
+
|
90
|
+
def to_csv(out_filename, short: false)
|
91
|
+
CSV.open("#{Dir.pwd}/#{out_filename}", 'w') do |csv|
|
92
|
+
#CSV header
|
93
|
+
csv << HEADER
|
94
|
+
#CSV content
|
95
|
+
stats.each do |path, stat|
|
96
|
+
csv << csv_format_row(path, stat, short)
|
97
|
+
end
|
98
|
+
end
|
99
|
+
end
|
100
|
+
|
66
101
|
private
|
67
102
|
|
68
|
-
def
|
103
|
+
def console_row(path, stat, short)
|
69
104
|
[
|
70
105
|
Utils.type_label(stat.type),
|
71
106
|
Utils.path_to_display(path, short: short, length: CONTENT_LENGTH),
|
@@ -76,6 +111,20 @@ module LogAnalyzer
|
|
76
111
|
]
|
77
112
|
end
|
78
113
|
|
114
|
+
def simple_row(path, stat, short)
|
115
|
+
[
|
116
|
+
stat.type,
|
117
|
+
Utils.path_to_display(path, short: short, length: CONTENT_LENGTH),
|
118
|
+
stat.count,
|
119
|
+
stat.avg,
|
120
|
+
stat.max,
|
121
|
+
stat.min,
|
122
|
+
]
|
123
|
+
end
|
124
|
+
|
125
|
+
alias :pdf_row :simple_row
|
126
|
+
alias :csv_format_row :simple_row
|
127
|
+
|
79
128
|
def new_table
|
80
129
|
Terminal::Table.new(headings: HEADER, width: DEFAULT_TABLE_WIDTH)
|
81
130
|
end
|
data/lib/log_analyzer/utils.rb
CHANGED
data/lib/log_analyzer/version.rb
CHANGED
data/log_analyzer.gemspec
CHANGED
@@ -26,6 +26,8 @@ Gem::Specification.new do |spec|
|
|
26
26
|
spec.add_dependency "rake"
|
27
27
|
spec.add_dependency "terminal-table"
|
28
28
|
spec.add_dependency "colorize"
|
29
|
+
spec.add_dependency "prawn"
|
30
|
+
spec.add_dependency "prawn-table"
|
29
31
|
|
30
32
|
spec.add_development_dependency "bundler", "> 1.14"
|
31
33
|
spec.add_development_dependency "rspec", "~> 3.0"
|
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.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Igor Kasyanchuk
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-02
|
11
|
+
date: 2018-03-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: thor
|
@@ -66,6 +66,34 @@ dependencies:
|
|
66
66
|
- - ">="
|
67
67
|
- !ruby/object:Gem::Version
|
68
68
|
version: '0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: prawn
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ">="
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
type: :runtime
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ">="
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: prawn-table
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - ">="
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0'
|
90
|
+
type: :runtime
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - ">="
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '0'
|
69
97
|
- !ruby/object:Gem::Dependency
|
70
98
|
name: bundler
|
71
99
|
requirement: !ruby/object:Gem::Requirement
|