log_sense 2.2.1 → 2.3.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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: c2acfa576d18214e05df5520518000955d12957756674c26a5fd63ac6efc9969
4
- data.tar.gz: 781b38f2a7118efe8f0c1ca0cba6d21bdf0a77bd3fe27a8c1dc27ca5cdc2b3e7
3
+ metadata.gz: 43c38b704af22a839fedec504755be79abf4307c1183efe65ee7323984c4d6bc
4
+ data.tar.gz: ed1b73c4b9ccc5e6ffcae7682e67124aa82dba1d9fde9ab625764207893a11dd
5
5
  SHA512:
6
- metadata.gz: bc877d0198d6f170addfd9a0972ed7df57df2d5c00fdac850808ab1f8f86c3ed3d2aa37cc1058f1c6ca1da86bbdc6e6e09a44778edca3a48aaf825f4d5aefa26
7
- data.tar.gz: ed99ed592a9a689fac9d319b1f346e705fcbbde021f45332d219097ed0df351d6b1d8a7bf2e0a72307b9932e2ab63ece7d0d8c2f2ef4fb9be45d14e2a5c6c863
6
+ metadata.gz: 19857e10b0f5b72afdb491245101050a3348e267d6a9409416ab478e72b441ed8b559280f492f1c761753cbfd71abdafd5184f60095c53ca1bc0640a83c22f4a
7
+ data.tar.gz: 3f049b2b6756bfe9ef872021f6b34263736b12eb75ec2b06f086387550fbd87efe367ccc4348070cb492f5870b286c626fe6244ab19ea01f74684d301175b32b
data/CHANGELOG.org CHANGED
@@ -2,6 +2,15 @@
2
2
  #+AUTHOR: Adolfo Villafiorita
3
3
  #+STARTUP: showall
4
4
 
5
+ * 2.3.1
6
+
7
+ - Updates geoip db
8
+ - Updates dependencies
9
+
10
+ * 2.3.0
11
+
12
+ - Adds average response time by day
13
+
5
14
  * 2.2.1
6
15
 
7
16
  - [Bug] Small fixes
data/Gemfile.lock CHANGED
@@ -1,50 +1,93 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- log_sense (2.2.0)
5
- browser (~> 5.3.0)
4
+ log_sense (2.3.1)
5
+ browser (~> 6.0.0)
6
6
  ipaddr (~> 1.2.0)
7
7
  iso_country_codes (~> 0.7.0)
8
- sqlite3 (~> 2.0.0)
9
- terminal-table (~> 3.0.0)
8
+ sqlite3 (~> 2.6.0)
9
+ terminal-table (~> 4.0.0)
10
10
 
11
11
  GEM
12
12
  remote: https://rubygems.org/
13
13
  specs:
14
- browser (5.3.1)
15
- debug (1.9.2)
14
+ ast (2.4.3)
15
+ browser (6.0.0)
16
+ bundle-audit (0.1.0)
17
+ bundler-audit
18
+ bundler-audit (0.9.2)
19
+ bundler (>= 1.2.0, < 3)
20
+ thor (~> 1.0)
21
+ date (3.4.1)
22
+ debug (1.10.0)
16
23
  irb (~> 1.10)
17
24
  reline (>= 0.3.8)
18
- io-console (0.7.2)
19
- ipaddr (1.2.6)
20
- irb (1.14.0)
25
+ io-console (0.8.0)
26
+ ipaddr (1.2.7)
27
+ irb (1.15.2)
28
+ pp (>= 0.6.0)
21
29
  rdoc (>= 4.0.0)
22
30
  reline (>= 0.4.2)
23
31
  iso_country_codes (0.7.8)
24
- mini_portile2 (2.8.7)
25
- minitest (5.24.1)
26
- psych (5.1.2)
32
+ json (2.12.0)
33
+ language_server-protocol (3.17.0.5)
34
+ lint_roller (1.1.0)
35
+ mini_portile2 (2.8.9)
36
+ minitest (5.25.5)
37
+ parallel (1.27.0)
38
+ parser (3.3.8.0)
39
+ ast (~> 2.4.1)
40
+ racc
41
+ pp (0.6.2)
42
+ prettyprint
43
+ prettyprint (0.2.0)
44
+ prism (1.4.0)
45
+ psych (5.2.6)
46
+ date
27
47
  stringio
48
+ racc (1.8.1)
49
+ rainbow (3.1.1)
28
50
  rake (13.2.1)
29
- rdoc (6.7.0)
51
+ rdoc (6.13.1)
30
52
  psych (>= 4.0.0)
31
- reline (0.5.9)
53
+ regexp_parser (2.10.0)
54
+ reline (0.6.1)
32
55
  io-console (~> 0.5)
33
- sqlite3 (2.0.3)
56
+ rubocop (1.75.5)
57
+ json (~> 2.3)
58
+ language_server-protocol (~> 3.17.0.2)
59
+ lint_roller (~> 1.1.0)
60
+ parallel (~> 1.10)
61
+ parser (>= 3.3.0.2)
62
+ rainbow (>= 2.2.2, < 4.0)
63
+ regexp_parser (>= 2.9.3, < 3.0)
64
+ rubocop-ast (>= 1.44.0, < 2.0)
65
+ ruby-progressbar (~> 1.7)
66
+ unicode-display_width (>= 2.4.0, < 4.0)
67
+ rubocop-ast (1.44.1)
68
+ parser (>= 3.3.7.2)
69
+ prism (~> 1.4)
70
+ ruby-progressbar (1.13.0)
71
+ sqlite3 (2.6.0)
34
72
  mini_portile2 (~> 2.8.0)
35
- stringio (3.1.1)
36
- terminal-table (3.0.2)
37
- unicode-display_width (>= 1.1.1, < 3)
38
- unicode-display_width (2.5.0)
73
+ stringio (3.1.7)
74
+ terminal-table (4.0.0)
75
+ unicode-display_width (>= 1.1.1, < 4)
76
+ thor (1.3.2)
77
+ unicode-display_width (3.1.4)
78
+ unicode-emoji (~> 4.0, >= 4.0.4)
79
+ unicode-emoji (4.0.4)
39
80
 
40
81
  PLATFORMS
41
82
  ruby
42
83
 
43
84
  DEPENDENCIES
44
- debug (~> 1.9.0)
85
+ bundle-audit
86
+ debug
45
87
  log_sense!
46
- minitest (~> 5.24.0)
88
+ minitest
47
89
  rake (~> 13.0)
90
+ rubocop
48
91
 
49
92
  BUNDLED WITH
50
93
  2.5.3
Binary file
@@ -21,33 +21,33 @@ module LogSense
21
21
  # 116.179.32.16 - - [19/Dec/2021:22:35:11 +0100] "GET / HTTP/1.1" 200 135 "-" "Mozilla/5.0 (compatible; Baiduspider/2.0; +http://www.baidu.com/search/spider.html)"
22
22
  #
23
23
  class LogLineParser
24
- DAY = /[0-9]{2}/
25
- MONTH = /[A-Za-z]{3}/
26
- YEAR = /[0-9]{4}/
27
- TIMEC = /[0-9]{2}/
28
- TIMEZONE = /(\+|-)[0-9]{4}/
24
+ DAY = "[0-9]{2}"
25
+ MONTH = "[A-Za-z]{3}"
26
+ YEAR = "[0-9]{4}"
27
+ TIMEC = "[0-9]{2}"
28
+ TIMEZONE = "(\\+|-)[0-9]{4}"
29
29
 
30
- IP = /(?<ip>[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}|::1|unknown)/
31
- IDENT = /(?<ident>[^ ]+|-)/
32
- USERID = /(?<userid>[^ ]+|-)/
30
+ IP = "(?<ip>[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}|::1|unknown)"
31
+ IDENT = "(?<ident>[^ ]+|-)"
32
+ USERID = "(?<userid>[^ ]+|-)"
33
33
 
34
- TIMESTAMP = /(?<date>#{DAY}\/#{MONTH}\/#{YEAR}):(?<time>#{TIMEC}:#{TIMEC}:#{TIMEC} #{TIMEZONE})/
34
+ TIMESTAMP = "(?<date>#{DAY}\\/#{MONTH}\\/#{YEAR}):(?<time>#{TIMEC}:#{TIMEC}:#{TIMEC} #{TIMEZONE})"
35
35
 
36
- HTTP_METHODS = /GET|HEAD|POST|PUT|DELETE|CONNECT|OPTIONS|TRACE|PATCH/
37
- WEBDAV_METHODS = /COPY|LOCK|MKCOL|MOVE|PROPFIND|PROPPATCH|UNLOCK/
38
- OTHER_METHODS = /SEARCH|REPORT|PRI|HEAD\/robots.txt/
39
- METHOD = /(?<method>#{HTTP_METHODS}|#{WEBDAV_METHODS}|#{OTHER_METHODS})/
40
- PROTOCOL = /(?<protocol>HTTP\/[0-9]\.[0-9]|-|.*)/
41
- URL = /(?<url>[^ ]+)/
42
- REFERER = /(?<referer>[^"]*)/
43
- RETURN_CODE = /(?<status>[1-5][0-9][0-9])/
44
- SIZE = /(?<size>[0-9]+|-)/
45
- USER_AGENT = /(?<user_agent>[^"]*)/
36
+ HTTP_METHODS = "GET|HEAD|POST|PUT|DELETE|CONNECT|OPTIONS|TRACE|PATCH"
37
+ WEBDAV_METHODS = "COPY|LOCK|MKCOL|MOVE|PROPFIND|PROPPATCH|UNLOCK"
38
+ OTHER_METHODS = "SEARCH|REPORT|PRI|HEAD/robots.txt"
39
+ METHOD = "(?<method>#{HTTP_METHODS}|#{WEBDAV_METHODS}|#{OTHER_METHODS})"
40
+ PROTOCOL = "(?<protocol>HTTP\/[0-9]\.[0-9]|-|.*)"
41
+ URL = "(?<url>[^ ]+)"
42
+ REFERER = '(?<referer>[^"]*)'
43
+ RETURN_CODE = "(?<status>[1-5][0-9][0-9])"
44
+ SIZE = "(?<size>[0-9]+|-)"
45
+ USER_AGENT = '(?<user_agent>[^"]*)'
46
46
 
47
47
  attr_reader :format
48
48
 
49
49
  def initialize
50
- @format = /#{IP} #{IDENT} #{USERID} \[#{TIMESTAMP}\] "(#{METHOD} #{URL} #{PROTOCOL}|-|.+)" #{RETURN_CODE} #{SIZE} "#{REFERER}" "#{USER_AGENT}"/
50
+ @format = /#{IP} #{IDENT} #{USERID} \[#{TIMESTAMP}\] "(#{METHOD} #{URL} #{PROTOCOL}|-|.+)" #{RETURN_CODE} #{SIZE} "#{REFERER}" "#{USER_AGENT}"/o
51
51
  end
52
52
 
53
53
  def parse(line)
@@ -54,6 +54,7 @@ module LogSense
54
54
 
55
55
  @most_requested_pages = @db.execute resource_query(html, gs)
56
56
  @most_requested_resources = @db.execute resource_query(non_html, gs)
57
+
57
58
  @missed_pages = @db.execute resource_query(html, bs)
58
59
  @missed_resources = @db.execute resource_query(non_html, bs)
59
60
 
@@ -139,7 +139,7 @@ module LogSense
139
139
 
140
140
  opts.on("-v", "--version", "Prints version information") do
141
141
  puts "log_sense version #{LogSense::VERSION}"
142
- puts "Copyright (C) 2021-2024 Shair.Tech"
142
+ puts "Copyright (C) 2021-2025 Shair.Tech"
143
143
  puts "Distributed under the terms of the MIT license"
144
144
  exit
145
145
  end
@@ -94,7 +94,7 @@ module LogSense
94
94
  method TEXT,
95
95
  request_format TEXT,
96
96
  anon_ip TEXT,
97
- timestamp TEXT
97
+ started_at TEXT
98
98
  )
99
99
  EOS
100
100
 
@@ -107,7 +107,7 @@ module LogSense
107
107
  method,
108
108
  request_format,
109
109
  anon_ip,
110
- timestamp
110
+ started_at
111
111
  )
112
112
  values (?, ?, ?, ?, ?, ?, ?, ?)
113
113
  EOS
@@ -550,7 +550,7 @@ module LogSense
550
550
  method: matchdata[:method],
551
551
  request_format: matchdata[:request_format],
552
552
  anon_ip: matchdata[:anon_ip],
553
- timestamp: matchdata[:timestamp],
553
+ started_at: matchdata[:timestamp],
554
554
  }
555
555
  end
556
556
  end
@@ -1,4 +1,7 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module LogSense
4
+ # Aggregate data from Logs
2
5
  class RailsAggregator < Aggregator
3
6
  WORDS_SEPARATOR = ' · '
4
7
 
@@ -42,6 +45,18 @@ module LogSense
42
45
  where #{filter}
43
46
  group by controller order by controller).gsub("\n", "")
44
47
 
48
+ @performance_over_time = @db.execute %(
49
+ SELECT strftime("%Y-%m-%d", ended_at),
50
+ count(controller),
51
+ printf("%.2f", min(duration_total_ms)),
52
+ printf("%.2f", avg(duration_total_ms)),
53
+ printf("%.2f", max(duration_total_ms))
54
+ from Event
55
+ where #{filter}
56
+ group by strftime("%Y-%m-%d", ended_at)
57
+ order by strftime("%Y-%m-%d", ended_at)
58
+ ).gsub("\n", "")
59
+
45
60
  #
46
61
  # Use the performance information to build a tree map.
47
62
  # We then compute by device and show the treemap and the table by device
@@ -1,4 +1,7 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module LogSense
4
+ # Specification of the Rails Reports
2
5
  class RailsReportShaper < ReportShaper
3
6
  def shape(data)
4
7
  [
@@ -42,6 +45,7 @@ module LogSense
42
45
  time_distribution(data),
43
46
  total_statuses(data),
44
47
  daily_statuses(data),
48
+ performance_over_time(data, col: "small-12 cell"),
45
49
  {
46
50
  title: "Rails Performance",
47
51
  header: %w[Controller Hits Min Avg Max],
@@ -86,6 +86,56 @@ module LogSense
86
86
  }
87
87
  end
88
88
 
89
+ def performance_over_time(data, colors: ["#d30001", "#888888"], col: "small-12 cell")
90
+ {
91
+ title: "Performance over Time",
92
+ header: %w[Date Count Min Avg Max],
93
+ column_alignment: %i[center right right right right],
94
+ rows: data[:performance_over_time],
95
+ col: col,
96
+ echarts_spec: "{
97
+ xAxis: {
98
+ type: 'category',
99
+ data: SERIES_DATA.map(row => row['Date'])
100
+ },
101
+ yAxis: [
102
+ {
103
+ type: 'value',
104
+ name: 'Average'
105
+ },
106
+ {
107
+ type: 'value',
108
+ name: 'Max'
109
+ }
110
+ ],
111
+ tooltip: {
112
+ trigger: 'axis'
113
+ },
114
+ series: [
115
+ {
116
+ data: SERIES_DATA.map(row => row['Avg']),
117
+ type: 'line',
118
+ color: '#{colors[0]}',
119
+ label: {
120
+ show: true,
121
+ position: 'top'
122
+ },
123
+ },
124
+ {
125
+ data: SERIES_DATA.map(row => row['Max']),
126
+ type: 'line',
127
+ color: '#{colors[1]}',
128
+ yAxisIndex: 1,
129
+ label: {
130
+ show: true,
131
+ position: 'top'
132
+ },
133
+ },
134
+ ]
135
+ }",
136
+ }
137
+ end
138
+
89
139
  #
90
140
  # Reports shared between rails and apache/nginx
91
141
  #
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module LogSense
2
- VERSION = "2.2.1"
4
+ VERSION = "2.3.1"
3
5
  end
data/log_sense.gemspec CHANGED
@@ -12,7 +12,7 @@ Gem::Specification.new do |spec|
12
12
  spec.license = "MIT"
13
13
  spec.required_ruby_version = Gem::Requirement.new(">= 2.6.9")
14
14
 
15
- spec.metadata["allowed_push_host"] = "https://rubygems.org/"
15
+ # spec.metadata["allowed_push_host"] = "https://rubygems.org/"
16
16
 
17
17
  spec.metadata["homepage_uri"] = spec.homepage
18
18
  spec.metadata["source_code_uri"] = "https://github.com/shair-tech/log_sense/"
@@ -27,12 +27,14 @@ Gem::Specification.new do |spec|
27
27
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
28
28
  spec.require_paths = ["lib"]
29
29
 
30
- spec.add_dependency "browser", "~> 5.3.0"
30
+ spec.add_dependency "browser", "~> 6.0.0"
31
31
  spec.add_dependency "ipaddr", "~> 1.2.0"
32
32
  spec.add_dependency "iso_country_codes", "~> 0.7.0"
33
- spec.add_dependency "sqlite3", "~> 2.0.0"
34
- spec.add_dependency "terminal-table", "~> 3.0.0"
33
+ spec.add_dependency "sqlite3", "~> 2.6.0"
34
+ spec.add_dependency "terminal-table", "~> 4.0.0"
35
35
 
36
- spec.add_development_dependency "debug", "~> 1.9.0"
37
- spec.add_development_dependency "minitest", "~> 5.24.0"
36
+ spec.add_development_dependency "debug"
37
+ spec.add_development_dependency "rubocop"
38
+ spec.add_development_dependency "bundle-audit"
39
+ spec.add_development_dependency "minitest"
38
40
  end
data/todo.org CHANGED
@@ -1,7 +1,10 @@
1
1
  #+TITLE: Todo
2
2
 
3
3
  * Todo (2024-08-01)
4
-
4
+ ** T Show page with method
5
+ - we could generate a page with the result of the calls to a given method
6
+ (how many calls, distribution, ...). This would be the "show" of a rails app.
7
+
5
8
  ** T Break rails log_parser in subclasses (one per log type)
6
9
 
7
10
  ** T Distinguish between exceptions, errors with no timestamps and errors with timestamps :feature:
metadata CHANGED
@@ -1,14 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: log_sense
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.2.1
4
+ version: 2.3.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Adolfo Villafiorita
8
- autorequire:
9
8
  bindir: exe
10
9
  cert_chain: []
11
- date: 2024-08-23 00:00:00.000000000 Z
10
+ date: 1980-01-02 00:00:00.000000000 Z
12
11
  dependencies:
13
12
  - !ruby/object:Gem::Dependency
14
13
  name: browser
@@ -16,14 +15,14 @@ dependencies:
16
15
  requirements:
17
16
  - - "~>"
18
17
  - !ruby/object:Gem::Version
19
- version: 5.3.0
18
+ version: 6.0.0
20
19
  type: :runtime
21
20
  prerelease: false
22
21
  version_requirements: !ruby/object:Gem::Requirement
23
22
  requirements:
24
23
  - - "~>"
25
24
  - !ruby/object:Gem::Version
26
- version: 5.3.0
25
+ version: 6.0.0
27
26
  - !ruby/object:Gem::Dependency
28
27
  name: ipaddr
29
28
  requirement: !ruby/object:Gem::Requirement
@@ -58,56 +57,84 @@ dependencies:
58
57
  requirements:
59
58
  - - "~>"
60
59
  - !ruby/object:Gem::Version
61
- version: 2.0.0
60
+ version: 2.6.0
62
61
  type: :runtime
63
62
  prerelease: false
64
63
  version_requirements: !ruby/object:Gem::Requirement
65
64
  requirements:
66
65
  - - "~>"
67
66
  - !ruby/object:Gem::Version
68
- version: 2.0.0
67
+ version: 2.6.0
69
68
  - !ruby/object:Gem::Dependency
70
69
  name: terminal-table
71
70
  requirement: !ruby/object:Gem::Requirement
72
71
  requirements:
73
72
  - - "~>"
74
73
  - !ruby/object:Gem::Version
75
- version: 3.0.0
74
+ version: 4.0.0
76
75
  type: :runtime
77
76
  prerelease: false
78
77
  version_requirements: !ruby/object:Gem::Requirement
79
78
  requirements:
80
79
  - - "~>"
81
80
  - !ruby/object:Gem::Version
82
- version: 3.0.0
81
+ version: 4.0.0
83
82
  - !ruby/object:Gem::Dependency
84
83
  name: debug
85
84
  requirement: !ruby/object:Gem::Requirement
86
85
  requirements:
87
- - - "~>"
86
+ - - ">="
88
87
  - !ruby/object:Gem::Version
89
- version: 1.9.0
88
+ version: '0'
90
89
  type: :development
91
90
  prerelease: false
92
91
  version_requirements: !ruby/object:Gem::Requirement
93
92
  requirements:
94
- - - "~>"
93
+ - - ">="
94
+ - !ruby/object:Gem::Version
95
+ version: '0'
96
+ - !ruby/object:Gem::Dependency
97
+ name: rubocop
98
+ requirement: !ruby/object:Gem::Requirement
99
+ requirements:
100
+ - - ">="
101
+ - !ruby/object:Gem::Version
102
+ version: '0'
103
+ type: :development
104
+ prerelease: false
105
+ version_requirements: !ruby/object:Gem::Requirement
106
+ requirements:
107
+ - - ">="
95
108
  - !ruby/object:Gem::Version
96
- version: 1.9.0
109
+ version: '0'
110
+ - !ruby/object:Gem::Dependency
111
+ name: bundle-audit
112
+ requirement: !ruby/object:Gem::Requirement
113
+ requirements:
114
+ - - ">="
115
+ - !ruby/object:Gem::Version
116
+ version: '0'
117
+ type: :development
118
+ prerelease: false
119
+ version_requirements: !ruby/object:Gem::Requirement
120
+ requirements:
121
+ - - ">="
122
+ - !ruby/object:Gem::Version
123
+ version: '0'
97
124
  - !ruby/object:Gem::Dependency
98
125
  name: minitest
99
126
  requirement: !ruby/object:Gem::Requirement
100
127
  requirements:
101
- - - "~>"
128
+ - - ">="
102
129
  - !ruby/object:Gem::Version
103
- version: 5.24.0
130
+ version: '0'
104
131
  type: :development
105
132
  prerelease: false
106
133
  version_requirements: !ruby/object:Gem::Requirement
107
134
  requirements:
108
- - - "~>"
135
+ - - ">="
109
136
  - !ruby/object:Gem::Version
110
- version: 5.24.0
137
+ version: '0'
111
138
  description: Generate analytics in HTML, txt, and SQLite format for Rails and Apache/Nginx
112
139
  log files.
113
140
  email:
@@ -172,11 +199,9 @@ homepage: https://github.com/shair-tech/log_sense/
172
199
  licenses:
173
200
  - MIT
174
201
  metadata:
175
- allowed_push_host: https://rubygems.org/
176
202
  homepage_uri: https://github.com/shair-tech/log_sense/
177
203
  source_code_uri: https://github.com/shair-tech/log_sense/
178
204
  changelog_uri: https://github.com/shair-tech/log_sense/blob/main/CHANGELOG.org
179
- post_install_message:
180
205
  rdoc_options: []
181
206
  require_paths:
182
207
  - lib
@@ -191,8 +216,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
191
216
  - !ruby/object:Gem::Version
192
217
  version: '0'
193
218
  requirements: []
194
- rubygems_version: 3.5.17
195
- signing_key:
219
+ rubygems_version: 3.6.7
196
220
  specification_version: 4
197
221
  summary: Generate analytics for Rails and Apache/Nginx log file.
198
222
  test_files: []