heroku_log_parser 0.0.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.
- data/.gitignore +17 -0
- data/Gemfile +4 -0
- data/LICENSE +22 -0
- data/README.md +36 -0
- data/Rakefile +2 -0
- data/heroku_log_parser.gemspec +23 -0
- data/lib/heroku_log_parser.rb +7 -0
- data/lib/heroku_log_parser/parser.rb +30 -0
- data/lib/heroku_log_parser/version.rb +3 -0
- data/spec/heroku_log_parser/parser_spec.rb +53 -0
- data/spec/spec_helper.rb +5 -0
- metadata +128 -0
data/.gitignore
ADDED
data/Gemfile
ADDED
data/LICENSE
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2012 Marcin Ciunelis
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,36 @@
|
|
1
|
+
# HerokuLogParser
|
2
|
+
|
3
|
+
Takes heroku log line as input and gives JSON output
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
gem 'heroku_log_parser'
|
10
|
+
|
11
|
+
And then execute:
|
12
|
+
|
13
|
+
$ bundle
|
14
|
+
|
15
|
+
Or install it yourself as:
|
16
|
+
|
17
|
+
$ gem install heroku_log_parser
|
18
|
+
|
19
|
+
## Usage
|
20
|
+
|
21
|
+
```ruby
|
22
|
+
require 'heroku_log_parser'
|
23
|
+
|
24
|
+
log_line = "2012-04-29T15:57:54+00:00 heroku[router]: GET www.foo.com/autocomplete/schools?q=Colegio+American dyno=web.4 queue=0 wait=0ms service=17ms status=200 bytes=496"
|
25
|
+
|
26
|
+
HerokuLogParser.parse(line)
|
27
|
+
#=> "{\"timestamp\":\"2012-04-29T15:57:50+00:00\",\"source\":\"heroku\",\"process\":\"web.4\",\"message\":\"Error R14 (Memory quota exceeded)\"}"
|
28
|
+
```
|
29
|
+
|
30
|
+
## Contributing
|
31
|
+
|
32
|
+
1. Fork it
|
33
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
34
|
+
3. Commit your changes (`git commit -am 'Added some feature'`)
|
35
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
36
|
+
5. Create new Pull Request
|
data/Rakefile
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
require File.expand_path('../lib/heroku_log_parser/version', __FILE__)
|
3
|
+
|
4
|
+
Gem::Specification.new do |gem|
|
5
|
+
gem.authors = ["Marcin Ciunelis"]
|
6
|
+
gem.email = ["marcin.ciunelis@gmail.com"]
|
7
|
+
gem.description = %q{Heroku Log Parser}
|
8
|
+
gem.summary = %q{Takes heroku log line as input and gives JSON output}
|
9
|
+
gem.homepage = ""
|
10
|
+
|
11
|
+
gem.files = `git ls-files`.split($\)
|
12
|
+
gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
|
13
|
+
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
|
14
|
+
gem.name = "heroku_log_parser"
|
15
|
+
gem.require_paths = ["lib"]
|
16
|
+
gem.version = HerokuLogParser::VERSION
|
17
|
+
|
18
|
+
gem.add_dependency "json"
|
19
|
+
|
20
|
+
gem.add_development_dependency "rake"
|
21
|
+
gem.add_development_dependency "rspec"
|
22
|
+
gem.add_development_dependency "json_spec"
|
23
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
require 'singleton'
|
2
|
+
|
3
|
+
module HerokuLogParser
|
4
|
+
class Parser
|
5
|
+
include Singleton
|
6
|
+
|
7
|
+
def parse_line(line)
|
8
|
+
matches = line.match(/^(.*?)\s(.*)\[(.*)\]\:\s(.*)$/)
|
9
|
+
|
10
|
+
JSON.generate({
|
11
|
+
timestamp: matches[1],
|
12
|
+
source: matches[2],
|
13
|
+
process: matches[3],
|
14
|
+
message: matches[4]
|
15
|
+
})
|
16
|
+
end
|
17
|
+
|
18
|
+
|
19
|
+
def parse(text)
|
20
|
+
parse_line(text)
|
21
|
+
end
|
22
|
+
|
23
|
+
class << self
|
24
|
+
def parse(text)
|
25
|
+
instance.parse(text)
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
end
|
30
|
+
end
|
@@ -0,0 +1,53 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
require "heroku_log_parser/parser"
|
3
|
+
|
4
|
+
describe HerokuLogParser::Parser do
|
5
|
+
|
6
|
+
subject { HerokuLogParser::Parser.parse(line) }
|
7
|
+
|
8
|
+
shared_examples_for "parser" do
|
9
|
+
it { should be_json_eql(json) }
|
10
|
+
end
|
11
|
+
|
12
|
+
context "heroku[router]" do
|
13
|
+
let(:line) { "2012-04-29T15:57:54+00:00 heroku[router]: GET www.foo.com/autocomplete/schools?q=Colegio+American dyno=web.4 queue=0 wait=0ms service=17ms status=200 bytes=496" }
|
14
|
+
let(:json) {
|
15
|
+
{
|
16
|
+
timestamp: "2012-04-29T15:57:54+00:00",
|
17
|
+
source: "heroku",
|
18
|
+
process: "router",
|
19
|
+
message: "GET www.foo.com/autocomplete/schools?q=Colegio+American dyno=web.4 queue=0 wait=0ms service=17ms status=200 bytes=496"
|
20
|
+
}.to_json
|
21
|
+
}
|
22
|
+
|
23
|
+
it_behaves_like "parser"
|
24
|
+
end
|
25
|
+
|
26
|
+
context "heroku[nginx]" do
|
27
|
+
let(:line) { %(2012-04-29T15:57:55+00:00 heroku[nginx]: 85.49.160.142 - - [29/Apr/2012:15:57:55 +0000] "GET /autocomplete/schools?q=Colegio+Am HTTP/1.1" 200 454 "http://www.foo.com/candidate/edit" "Mozilla/5.0 (Windows NT 6.0) AppleWebKit/535.19 (KHTML, like Gecko) Chrome/18.0.1025.162 Safari/535.19" www.foo.com) }
|
28
|
+
let(:json) {
|
29
|
+
{
|
30
|
+
timestamp: "2012-04-29T15:57:55+00:00",
|
31
|
+
source: "heroku",
|
32
|
+
process: "nginx",
|
33
|
+
message: %(85.49.160.142 - - [29/Apr/2012:15:57:55 +0000] "GET /autocomplete/schools?q=Colegio+Am HTTP/1.1" 200 454 "http://www.foo.com/candidate/edit" "Mozilla/5.0 (Windows NT 6.0) AppleWebKit/535.19 (KHTML, like Gecko) Chrome/18.0.1025.162 Safari/535.19" www.foo.com)
|
34
|
+
}.to_json
|
35
|
+
}
|
36
|
+
|
37
|
+
it_behaves_like "parser"
|
38
|
+
end
|
39
|
+
|
40
|
+
context "heroku[process.X]" do
|
41
|
+
let(:line) { %(2012-04-29T15:57:50+00:00 heroku[web.4]: Error R14 (Memory quota exceeded)) }
|
42
|
+
let(:json) {
|
43
|
+
{
|
44
|
+
timestamp: "2012-04-29T15:57:50+00:00",
|
45
|
+
source: "heroku",
|
46
|
+
process: "web.4",
|
47
|
+
message: "Error R14 (Memory quota exceeded)"
|
48
|
+
}.to_json
|
49
|
+
}
|
50
|
+
|
51
|
+
it_behaves_like "parser"
|
52
|
+
end
|
53
|
+
end
|
data/spec/spec_helper.rb
ADDED
metadata
ADDED
@@ -0,0 +1,128 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: heroku_log_parser
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Marcin Ciunelis
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2012-04-29 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: json
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ! '>='
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '0'
|
22
|
+
type: :runtime
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ! '>='
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: '0'
|
30
|
+
- !ruby/object:Gem::Dependency
|
31
|
+
name: rake
|
32
|
+
requirement: !ruby/object:Gem::Requirement
|
33
|
+
none: false
|
34
|
+
requirements:
|
35
|
+
- - ! '>='
|
36
|
+
- !ruby/object:Gem::Version
|
37
|
+
version: '0'
|
38
|
+
type: :development
|
39
|
+
prerelease: false
|
40
|
+
version_requirements: !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
42
|
+
requirements:
|
43
|
+
- - ! '>='
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: '0'
|
46
|
+
- !ruby/object:Gem::Dependency
|
47
|
+
name: rspec
|
48
|
+
requirement: !ruby/object:Gem::Requirement
|
49
|
+
none: false
|
50
|
+
requirements:
|
51
|
+
- - ! '>='
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: '0'
|
54
|
+
type: :development
|
55
|
+
prerelease: false
|
56
|
+
version_requirements: !ruby/object:Gem::Requirement
|
57
|
+
none: false
|
58
|
+
requirements:
|
59
|
+
- - ! '>='
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
- !ruby/object:Gem::Dependency
|
63
|
+
name: json_spec
|
64
|
+
requirement: !ruby/object:Gem::Requirement
|
65
|
+
none: false
|
66
|
+
requirements:
|
67
|
+
- - ! '>='
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
version: '0'
|
70
|
+
type: :development
|
71
|
+
prerelease: false
|
72
|
+
version_requirements: !ruby/object:Gem::Requirement
|
73
|
+
none: false
|
74
|
+
requirements:
|
75
|
+
- - ! '>='
|
76
|
+
- !ruby/object:Gem::Version
|
77
|
+
version: '0'
|
78
|
+
description: Heroku Log Parser
|
79
|
+
email:
|
80
|
+
- marcin.ciunelis@gmail.com
|
81
|
+
executables: []
|
82
|
+
extensions: []
|
83
|
+
extra_rdoc_files: []
|
84
|
+
files:
|
85
|
+
- .gitignore
|
86
|
+
- Gemfile
|
87
|
+
- LICENSE
|
88
|
+
- README.md
|
89
|
+
- Rakefile
|
90
|
+
- heroku_log_parser.gemspec
|
91
|
+
- lib/heroku_log_parser.rb
|
92
|
+
- lib/heroku_log_parser/parser.rb
|
93
|
+
- lib/heroku_log_parser/version.rb
|
94
|
+
- spec/heroku_log_parser/parser_spec.rb
|
95
|
+
- spec/spec_helper.rb
|
96
|
+
homepage: ''
|
97
|
+
licenses: []
|
98
|
+
post_install_message:
|
99
|
+
rdoc_options: []
|
100
|
+
require_paths:
|
101
|
+
- lib
|
102
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
103
|
+
none: false
|
104
|
+
requirements:
|
105
|
+
- - ! '>='
|
106
|
+
- !ruby/object:Gem::Version
|
107
|
+
version: '0'
|
108
|
+
segments:
|
109
|
+
- 0
|
110
|
+
hash: -1799866966709517165
|
111
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
112
|
+
none: false
|
113
|
+
requirements:
|
114
|
+
- - ! '>='
|
115
|
+
- !ruby/object:Gem::Version
|
116
|
+
version: '0'
|
117
|
+
segments:
|
118
|
+
- 0
|
119
|
+
hash: -1799866966709517165
|
120
|
+
requirements: []
|
121
|
+
rubyforge_project:
|
122
|
+
rubygems_version: 1.8.23
|
123
|
+
signing_key:
|
124
|
+
specification_version: 3
|
125
|
+
summary: Takes heroku log line as input and gives JSON output
|
126
|
+
test_files:
|
127
|
+
- spec/heroku_log_parser/parser_spec.rb
|
128
|
+
- spec/spec_helper.rb
|