myslog 0.0.4 → 0.0.5
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +21 -17
- data/lib/myslog.rb +7 -2
- data/myslog.gemspec +1 -1
- metadata +10 -5
data/README.md
CHANGED
@@ -16,25 +16,29 @@ Usage
|
|
16
16
|
```ruby
|
17
17
|
myslog = MySlog.new
|
18
18
|
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
19
|
+
text = <<-EOF
|
20
|
+
# Time: 111003 14:17:38
|
21
|
+
# User@Host: root[root] @ localhost []
|
22
|
+
# Query_time: 0.000270 Lock_time: 0.000097 Rows_sent: 1 Rows_examined: 0
|
23
|
+
SET timestamp=1317619058;
|
24
|
+
SELECT * FROM life;
|
25
|
+
EOF
|
26
|
+
|
27
|
+
records = myslog.parse(text)
|
24
28
|
```
|
25
29
|
|
26
|
-
`
|
30
|
+
`records` is Array of Hash
|
27
31
|
|
28
32
|
```ruby
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
33
|
+
record = records.first
|
34
|
+
|
35
|
+
record[:time] #=> Time(20111003 14:17:38)
|
36
|
+
record[:user] #=> "root[root]"
|
37
|
+
record[:host] #=> "localhost"
|
38
|
+
record[:host_ip] #=> ""
|
39
|
+
record[:query_time] #=> 0.000270
|
40
|
+
record[:lock_time] #=> 0.000097
|
41
|
+
record[:rows_sent] #=> 1
|
42
|
+
record[:rows_examined] #=> 0
|
43
|
+
record[:sql] #=> "SET timestamp=1317619058; SELECT * FROM life;"
|
40
44
|
```
|
data/lib/myslog.rb
CHANGED
@@ -66,8 +66,13 @@ class MySlog
|
|
66
66
|
|
67
67
|
elems = record.split(" ")
|
68
68
|
response[:user] = elems[2].strip
|
69
|
-
|
70
|
-
|
69
|
+
if elems[5] == nil
|
70
|
+
response[:host] = nil
|
71
|
+
response[:host_ip] = elems[4].strip[1...-1]
|
72
|
+
else
|
73
|
+
response[:host] = elems[4].strip
|
74
|
+
response[:host_ip] = elems[5].strip[1...-1]
|
75
|
+
end
|
71
76
|
|
72
77
|
record = records.shift
|
73
78
|
elems = record.split(" ")
|
data/myslog.gemspec
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: myslog
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.5
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,11 +9,11 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-
|
12
|
+
date: 2012-08-18 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rspec
|
16
|
-
requirement:
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ! '>='
|
@@ -21,7 +21,12 @@ dependencies:
|
|
21
21
|
version: '0'
|
22
22
|
type: :development
|
23
23
|
prerelease: false
|
24
|
-
version_requirements:
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ! '>='
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: '0'
|
25
30
|
description: MySQL slow query parser.
|
26
31
|
email:
|
27
32
|
- taka84u9@gmail.com
|
@@ -58,7 +63,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
58
63
|
version: '0'
|
59
64
|
requirements: []
|
60
65
|
rubyforge_project:
|
61
|
-
rubygems_version: 1.8.
|
66
|
+
rubygems_version: 1.8.23
|
62
67
|
signing_key:
|
63
68
|
specification_version: 3
|
64
69
|
summary: MySQL slow query parser.
|