blooper 1.7 → 1.8
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/{COPYING → COPYRIGHT} +1 -1
- data/{README.rdoc → README.md} +10 -10
- data/lib/blooper.rb +2 -3
- data/lib/blooper/input.rb +7 -5
- data/lib/blooper/tuple.rb +11 -2
- data/lib/blooper/version.rb +1 -1
- metadata +12 -12
data/{COPYING → COPYRIGHT}
RENAMED
data/{README.rdoc → README.md}
RENAMED
@@ -1,32 +1,32 @@
|
|
1
|
-
|
1
|
+
# Welcome to blooper
|
2
2
|
|
3
|
-
|
3
|
+
[Blooper](http://www.mariowiki.com/Blooper) is squid-like creatures that are found in the ocean.
|
4
4
|
It can also write squid access log into a database (I believe any sequel-support database).
|
5
5
|
Should you write a squid access log into a data base, you won't have to catch a blooper in the ocean of errors for that.
|
6
6
|
I have already tamed one, and you are free to use it.
|
7
7
|
|
8
|
-
The idea is shamelessly stolen from
|
8
|
+
The idea is shamelessly stolen from [logmysqldaemon](http://sourceforge.net/projects/logmysqldaemon/) script.
|
9
9
|
|
10
|
-
|
10
|
+
# Installation
|
11
11
|
|
12
12
|
gem install (pg|mysql|oracle|sqlite|etc sequel database adapter)
|
13
13
|
gem install blooper
|
14
14
|
|
15
|
-
|
15
|
+
# Squid configuration
|
16
16
|
|
17
17
|
logformat squid_log time %{%Y-%m-%d_%H:%M:%S%z}tl time_response %tr ip_source %>a squid_request_status %Ss http_status_code %03>Hs http_reply_size %<st http_request_method %rm http_request_url %ru user_name %un squid_hier_code %Sh ip_destination %<a http_content_type %mt
|
18
|
-
access_log daemon:{adapter:postgres,database:squid,username:squid,password:squid,host:db} squid_log
|
18
|
+
access_log daemon:{adapter:postgres,database:squid,username:squid,password:squid,host:db,encoding:utf8} squid_log
|
19
19
|
logfile_daemon /usr/local/bin/blooper
|
20
20
|
|
21
|
-
1. The column names are dynamic, here time is a column name,
|
21
|
+
1. The column names are dynamic, here time is a column name, [%{%Y-%m-%d_%H:%M:%S%z}](http://www.squid-cache.org/Versions/v3/3.2/cfgman/logformat.html) is a value that will be written into that column.
|
22
22
|
|
23
|
-
2. The second string contains database access information, the credential depends on
|
23
|
+
2. The second string contains database access information, the credential depends on [adapter](http://sequel.rubyforge.org/rdoc/files/doc/opening_databases_rdoc.html), tested only with postgres.
|
24
24
|
|
25
25
|
3. The third string is a full path to the executable ($ which blooper).
|
26
26
|
|
27
|
-
|
27
|
+
# Database configuration
|
28
28
|
|
29
29
|
createdb squid
|
30
|
-
psql squid < pg.schema
|
30
|
+
psql squid < sql/pg.schema
|
31
31
|
|
32
32
|
Or use your own schema integration, just specify the proper format into the logformat variable in squid.conf.
|
data/lib/blooper.rb
CHANGED
@@ -25,16 +25,15 @@ module Blooper
|
|
25
25
|
super('Blooper')
|
26
26
|
self.level = $VERBOSE && Logger::DEBUG || LOGGER_LEVEL
|
27
27
|
self.logger.formatter = formatter
|
28
|
-
@input = Input.new
|
29
28
|
end
|
30
29
|
|
31
30
|
def run
|
32
31
|
@log.info('Establishing the database connection')
|
33
32
|
DB.instance
|
34
33
|
@log.info('A database connection has been established')
|
35
|
-
|
34
|
+
Input.each do |tuple|
|
36
35
|
begin
|
37
|
-
|
36
|
+
tuple.save
|
38
37
|
@log.debug('Data was saved')
|
39
38
|
rescue Sequel::DatabaseDisconnectError
|
40
39
|
@log.warn('A database connection has been lost, reconnecting...')
|
data/lib/blooper/input.rb
CHANGED
@@ -1,14 +1,16 @@
|
|
1
1
|
module Blooper
|
2
2
|
class Input
|
3
3
|
|
4
|
-
|
5
|
-
|
4
|
+
attr_reader :flow
|
5
|
+
|
6
|
+
def initialize(flow = STDIN)
|
7
|
+
@flow = flow
|
6
8
|
end
|
7
9
|
|
8
|
-
def each
|
9
|
-
|
10
|
+
def self.each(*args)
|
11
|
+
Input.new(*args).flow.each do |line|
|
10
12
|
line = Line.new(line)
|
11
|
-
yield Tuple.new(line.clean) if line.valid?
|
13
|
+
yield Tuple.new(line.clean) if line.valid? rescue ArgumentError
|
12
14
|
end
|
13
15
|
end
|
14
16
|
|
data/lib/blooper/tuple.rb
CHANGED
@@ -1,18 +1,27 @@
|
|
1
1
|
module Blooper
|
2
2
|
class Tuple
|
3
3
|
|
4
|
+
SQL = {'-' => nil}
|
5
|
+
|
4
6
|
def initialize(line)
|
5
7
|
@line = line
|
6
8
|
end
|
7
9
|
|
8
10
|
def tuples
|
9
|
-
|
10
|
-
h.merge(h) {|k,v| v.eql?('-') ? nil : v}
|
11
|
+
Hash[*sql]
|
11
12
|
end
|
12
13
|
|
13
14
|
def save
|
14
15
|
DB.instance.insert(tuples)
|
15
16
|
end
|
16
17
|
|
18
|
+
private
|
19
|
+
|
20
|
+
def sql
|
21
|
+
@line.split.map do |raw|
|
22
|
+
SQL.has_key?(raw) ? SQL[raw] : raw
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
17
26
|
end
|
18
27
|
end
|
data/lib/blooper/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: blooper
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: '1.
|
4
|
+
version: '1.8'
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -18,7 +18,7 @@ dependencies:
|
|
18
18
|
requirements:
|
19
19
|
- - ~>
|
20
20
|
- !ruby/object:Gem::Version
|
21
|
-
version: '2.
|
21
|
+
version: '2.11'
|
22
22
|
type: :development
|
23
23
|
prerelease: false
|
24
24
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -26,13 +26,13 @@ dependencies:
|
|
26
26
|
requirements:
|
27
27
|
- - ~>
|
28
28
|
- !ruby/object:Gem::Version
|
29
|
-
version: '2.
|
29
|
+
version: '2.11'
|
30
30
|
- !ruby/object:Gem::Dependency
|
31
31
|
name: sequel
|
32
32
|
requirement: !ruby/object:Gem::Requirement
|
33
33
|
none: false
|
34
34
|
requirements:
|
35
|
-
- -
|
35
|
+
- - '>='
|
36
36
|
- !ruby/object:Gem::Version
|
37
37
|
version: 3.38.0
|
38
38
|
type: :runtime
|
@@ -40,7 +40,7 @@ dependencies:
|
|
40
40
|
version_requirements: !ruby/object:Gem::Requirement
|
41
41
|
none: false
|
42
42
|
requirements:
|
43
|
-
- -
|
43
|
+
- - '>='
|
44
44
|
- !ruby/object:Gem::Version
|
45
45
|
version: 3.38.0
|
46
46
|
- !ruby/object:Gem::Dependency
|
@@ -48,7 +48,7 @@ dependencies:
|
|
48
48
|
requirement: !ruby/object:Gem::Requirement
|
49
49
|
none: false
|
50
50
|
requirements:
|
51
|
-
- -
|
51
|
+
- - '>='
|
52
52
|
- !ruby/object:Gem::Version
|
53
53
|
version: '0'
|
54
54
|
type: :development
|
@@ -56,7 +56,7 @@ dependencies:
|
|
56
56
|
version_requirements: !ruby/object:Gem::Requirement
|
57
57
|
none: false
|
58
58
|
requirements:
|
59
|
-
- -
|
59
|
+
- - '>='
|
60
60
|
- !ruby/object:Gem::Version
|
61
61
|
version: '0'
|
62
62
|
description: work through squid access log daemon
|
@@ -73,8 +73,8 @@ files:
|
|
73
73
|
- lib/blooper/tuple.rb
|
74
74
|
- lib/blooper/db.rb
|
75
75
|
- lib/blooper/version.rb
|
76
|
-
-
|
77
|
-
- README.
|
76
|
+
- COPYRIGHT
|
77
|
+
- README.md
|
78
78
|
homepage: https://github.com/paranormal/blooper
|
79
79
|
licenses:
|
80
80
|
- bsd
|
@@ -85,18 +85,18 @@ require_paths:
|
|
85
85
|
required_ruby_version: !ruby/object:Gem::Requirement
|
86
86
|
none: false
|
87
87
|
requirements:
|
88
|
-
- -
|
88
|
+
- - '>='
|
89
89
|
- !ruby/object:Gem::Version
|
90
90
|
version: 1.9.0
|
91
91
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
92
92
|
none: false
|
93
93
|
requirements:
|
94
|
-
- -
|
94
|
+
- - '>='
|
95
95
|
- !ruby/object:Gem::Version
|
96
96
|
version: 1.3.6
|
97
97
|
requirements: []
|
98
98
|
rubyforge_project:
|
99
|
-
rubygems_version: 1.8.
|
99
|
+
rubygems_version: 1.8.25
|
100
100
|
signing_key:
|
101
101
|
specification_version: 3
|
102
102
|
summary: squid's access log collector — Read more
|