ralose 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.document +5 -0
- data/Gemfile +15 -0
- data/Gemfile.lock +70 -0
- data/LICENSE.txt +20 -0
- data/README.rdoc +63 -0
- data/Rakefile +44 -0
- data/VERSION +1 -0
- data/bin/ralose +8 -0
- data/lib/ralose.rb +2 -0
- data/lib/ralose/command.rb +122 -0
- data/ralose.gemspec +57 -0
- data/test/fixtures/sample.log +29 -0
- data/test/helper.rb +18 -0
- data/test/test_ralose.rb +56 -0
- metadata +88 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 4e2458587f34db717f4a1ac86cb2a65b5d01ac1129a52a8c0b651e4f9e01d68d
|
4
|
+
data.tar.gz: f3f8de3a14d4bf92f5085ef7faa0a073f0a1f337421a03b64410994beab8b692
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 843ccf1c511ce00bc1b99549efb004a93efeb52125f16658f8346a0afabeeb55207330c3bf3c23ca2564279c19c764cf4ca6f511380b1b02f03b89b44d881208
|
7
|
+
data.tar.gz: a6998bd980d67406030c60bac939678eab09a97a2959f7fba5fa12d7c1b3e4efdf70c3810b0cddd09a562a4e017af701cf8be589ef95202a0ba361b83c58f1a4
|
data/.document
ADDED
data/Gemfile
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
source "https://rubygems.org"
|
2
|
+
|
3
|
+
group :development do
|
4
|
+
gem "rdoc", "~> 6.0.4"
|
5
|
+
gem "jeweler", "~> 2.3.1"
|
6
|
+
end
|
7
|
+
|
8
|
+
group :test do
|
9
|
+
gem "test-unit", "~> 3.2.8"
|
10
|
+
end
|
11
|
+
|
12
|
+
group :xzibit do
|
13
|
+
# Allows use of `bundle exec ralose` in development.
|
14
|
+
gem 'ralose', path: '.'
|
15
|
+
end
|
data/Gemfile.lock
ADDED
@@ -0,0 +1,70 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
ralose (0.0.1)
|
5
|
+
|
6
|
+
GEM
|
7
|
+
remote: https://rubygems.org/
|
8
|
+
specs:
|
9
|
+
addressable (2.4.0)
|
10
|
+
builder (3.2.3)
|
11
|
+
descendants_tracker (0.0.4)
|
12
|
+
thread_safe (~> 0.3, >= 0.3.1)
|
13
|
+
faraday (0.9.2)
|
14
|
+
multipart-post (>= 1.2, < 3)
|
15
|
+
git (1.4.0)
|
16
|
+
github_api (0.16.0)
|
17
|
+
addressable (~> 2.4.0)
|
18
|
+
descendants_tracker (~> 0.0.4)
|
19
|
+
faraday (~> 0.8, < 0.10)
|
20
|
+
hashie (>= 3.4)
|
21
|
+
mime-types (>= 1.16, < 3.0)
|
22
|
+
oauth2 (~> 1.0)
|
23
|
+
hashie (3.5.7)
|
24
|
+
highline (1.7.10)
|
25
|
+
jeweler (2.3.9)
|
26
|
+
builder
|
27
|
+
bundler
|
28
|
+
git (>= 1.2.5)
|
29
|
+
github_api (~> 0.16.0)
|
30
|
+
highline (>= 1.6.15)
|
31
|
+
nokogiri (>= 1.5.10)
|
32
|
+
psych
|
33
|
+
rake
|
34
|
+
rdoc
|
35
|
+
semver2
|
36
|
+
jwt (1.5.6)
|
37
|
+
mime-types (2.99.3)
|
38
|
+
mini_portile2 (2.3.0)
|
39
|
+
multi_json (1.13.1)
|
40
|
+
multi_xml (0.6.0)
|
41
|
+
multipart-post (2.0.0)
|
42
|
+
nokogiri (1.8.2)
|
43
|
+
mini_portile2 (~> 2.3.0)
|
44
|
+
oauth2 (1.4.0)
|
45
|
+
faraday (>= 0.8, < 0.13)
|
46
|
+
jwt (~> 1.0)
|
47
|
+
multi_json (~> 1.3)
|
48
|
+
multi_xml (~> 0.5)
|
49
|
+
rack (>= 1.2, < 3)
|
50
|
+
power_assert (1.1.1)
|
51
|
+
psych (3.0.2)
|
52
|
+
rack (2.0.5)
|
53
|
+
rake (12.3.1)
|
54
|
+
rdoc (6.0.4)
|
55
|
+
semver2 (3.4.2)
|
56
|
+
test-unit (3.2.8)
|
57
|
+
power_assert
|
58
|
+
thread_safe (0.3.6)
|
59
|
+
|
60
|
+
PLATFORMS
|
61
|
+
ruby
|
62
|
+
|
63
|
+
DEPENDENCIES
|
64
|
+
jeweler (~> 2.3.1)
|
65
|
+
ralose!
|
66
|
+
rdoc (~> 6.0.4)
|
67
|
+
test-unit (~> 3.2.8)
|
68
|
+
|
69
|
+
BUNDLED WITH
|
70
|
+
1.16.1
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2018 Douglas F Shearer
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.rdoc
ADDED
@@ -0,0 +1,63 @@
|
|
1
|
+
= RaLoSe - Rails Log Search
|
2
|
+
|
3
|
+
Search Rails logs for a string - get all the log lines for matching requests.
|
4
|
+
|
5
|
+
RaLoSe uses Rails request IDs to group lines from the same request. Make sure you have these configured in your environment. For example, ensure `config/env/production.rb` has the line:
|
6
|
+
|
7
|
+
```
|
8
|
+
config.log_tags = [ :request_id ]
|
9
|
+
```
|
10
|
+
|
11
|
+
== Install
|
12
|
+
|
13
|
+
Either install the Gem:
|
14
|
+
|
15
|
+
```
|
16
|
+
gem install ralose
|
17
|
+
```
|
18
|
+
|
19
|
+
Or add to your Gemfile if using as part of a project:
|
20
|
+
|
21
|
+
```
|
22
|
+
gem "ralose"
|
23
|
+
```
|
24
|
+
|
25
|
+
Then `bundle install`.
|
26
|
+
|
27
|
+
|
28
|
+
== Usage
|
29
|
+
|
30
|
+
You can either pass a file:
|
31
|
+
|
32
|
+
```
|
33
|
+
ralose foobar log/production.log
|
34
|
+
```
|
35
|
+
|
36
|
+
or pipe a file to STDIN:
|
37
|
+
|
38
|
+
```
|
39
|
+
tail -f log/production.log | ralose foobar
|
40
|
+
```
|
41
|
+
|
42
|
+
In both cases `ralose` will output requests which match the search string `foobar`.
|
43
|
+
|
44
|
+
For additional options, run `ralose -h`.
|
45
|
+
|
46
|
+
|
47
|
+
== Contributing to RaLoSe
|
48
|
+
|
49
|
+
Source is available on Github at https://github.com/dougal/ralose.
|
50
|
+
|
51
|
+
* Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet.
|
52
|
+
* Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it.
|
53
|
+
* Fork the project.
|
54
|
+
* Start a feature/bugfix branch.
|
55
|
+
* Commit and push until you are happy with your contribution.
|
56
|
+
* Make sure to add tests for it. This is important so I don't break it in a future version unintentionally.
|
57
|
+
* Please try not to mess with the Rakefile, version, or history. If you want to have your own version, or is otherwise necessary, that is fine, but please isolate to its own commit so I can cherry-pick around it.
|
58
|
+
|
59
|
+
== Copyright
|
60
|
+
|
61
|
+
Copyright (c) 2018 Douglas F Shearer. See LICENSE.txt for
|
62
|
+
further details.
|
63
|
+
|
data/Rakefile
ADDED
@@ -0,0 +1,44 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
require 'rubygems'
|
4
|
+
require 'bundler'
|
5
|
+
begin
|
6
|
+
Bundler.setup(:default, :development, :xzibit)
|
7
|
+
rescue Bundler::BundlerError => e
|
8
|
+
$stderr.puts e.message
|
9
|
+
$stderr.puts "Run `bundle install` to install missing gems"
|
10
|
+
exit e.status_code
|
11
|
+
end
|
12
|
+
require 'rake'
|
13
|
+
|
14
|
+
require 'jeweler'
|
15
|
+
Jeweler::Tasks.new do |gem|
|
16
|
+
gem.name = "ralose"
|
17
|
+
gem.homepage = "http://github.com/dougal/ralose"
|
18
|
+
gem.license = "MIT"
|
19
|
+
gem.summary = "Search Rails logs for a string - get all the log lines for matching requests."
|
20
|
+
gem.email = "dougal.s@gmail.com"
|
21
|
+
gem.authors = ["Douglas F Shearer"]
|
22
|
+
gem.executables = ['ralose']
|
23
|
+
# Define dependencies in Gemfile.
|
24
|
+
end
|
25
|
+
Jeweler::RubygemsDotOrgTasks.new
|
26
|
+
|
27
|
+
require 'rake/testtask'
|
28
|
+
Rake::TestTask.new(:test) do |test|
|
29
|
+
test.libs << 'lib' << 'test'
|
30
|
+
test.pattern = 'test/**/test_*.rb'
|
31
|
+
test.verbose = true
|
32
|
+
end
|
33
|
+
|
34
|
+
task :default => :test
|
35
|
+
|
36
|
+
require 'rdoc/task'
|
37
|
+
Rake::RDocTask.new do |rdoc|
|
38
|
+
version = File.exist?('VERSION') ? File.read('VERSION') : ""
|
39
|
+
|
40
|
+
rdoc.rdoc_dir = 'rdoc'
|
41
|
+
rdoc.title = "ralose #{version}"
|
42
|
+
rdoc.rdoc_files.include('README*')
|
43
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
44
|
+
end
|
data/VERSION
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
0.1.0
|
data/bin/ralose
ADDED
data/lib/ralose.rb
ADDED
@@ -0,0 +1,122 @@
|
|
1
|
+
require 'optparse'
|
2
|
+
|
3
|
+
module RaLoSe
|
4
|
+
class Command
|
5
|
+
|
6
|
+
RED = "\e[31m".freeze
|
7
|
+
RESET_COLOR = "\e[0m".freeze
|
8
|
+
|
9
|
+
# [a9c56d04-d706-49ae-b0a2-e7636c650d5e]
|
10
|
+
REQUEST_ID_RE = /\[[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}\]/.freeze
|
11
|
+
|
12
|
+
def initialize
|
13
|
+
@colorized_output = true
|
14
|
+
@case_insensitive = false
|
15
|
+
|
16
|
+
parse_options
|
17
|
+
|
18
|
+
@current_request_id = nil
|
19
|
+
@current_request_lines = []
|
20
|
+
@print_current_request = false
|
21
|
+
|
22
|
+
@query = Regexp.new(ARGV.shift, @case_insensitive)
|
23
|
+
end
|
24
|
+
|
25
|
+
def self.run!
|
26
|
+
new.run!
|
27
|
+
end
|
28
|
+
|
29
|
+
def run!
|
30
|
+
# Pipe handling based on: https://www.jstorimer.com/blogs/workingwithcode/7766125-writing-ruby-scripts-that-respect-pipelines
|
31
|
+
|
32
|
+
# Read from file passed in ARGV, or STDIN.
|
33
|
+
ARGF.each_line do |line|
|
34
|
+
|
35
|
+
request_id = line[REQUEST_ID_RE]
|
36
|
+
|
37
|
+
if request_id.nil?
|
38
|
+
next
|
39
|
+
end
|
40
|
+
|
41
|
+
if request_id != @current_request_id
|
42
|
+
print_current_request
|
43
|
+
new_request(request_id)
|
44
|
+
end
|
45
|
+
|
46
|
+
if line.match?(@query)
|
47
|
+
@print_current_request = true
|
48
|
+
|
49
|
+
if @colorized_output
|
50
|
+
line.gsub!(@query, "#{RED}\\0#{RESET_COLOR}")
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
@current_request_lines << line
|
55
|
+
|
56
|
+
end
|
57
|
+
|
58
|
+
print_current_request
|
59
|
+
|
60
|
+
end
|
61
|
+
|
62
|
+
private
|
63
|
+
|
64
|
+
def new_request(request_id)
|
65
|
+
@current_request_id = request_id
|
66
|
+
@current_request_lines = []
|
67
|
+
@print_current_request = false
|
68
|
+
end
|
69
|
+
|
70
|
+
def print_current_request
|
71
|
+
if !@print_current_request
|
72
|
+
return
|
73
|
+
end
|
74
|
+
|
75
|
+
@current_request_lines.each do |line|
|
76
|
+
print_line(line)
|
77
|
+
end
|
78
|
+
|
79
|
+
# TODO: Print newlines above the 2nd request onwards?
|
80
|
+
print_line("\n\n")
|
81
|
+
end
|
82
|
+
|
83
|
+
def print_line(line)
|
84
|
+
begin
|
85
|
+
$stdout.puts line
|
86
|
+
|
87
|
+
# Handle case where output pipe is closed before writing is completed.
|
88
|
+
rescue Errno::EPIPE
|
89
|
+
exit(74)
|
90
|
+
end
|
91
|
+
end
|
92
|
+
|
93
|
+
def parse_options
|
94
|
+
OptionParser.new do |options|
|
95
|
+
# This banner is the first line of the help documentation.
|
96
|
+
options.banner = "Usage: ralose [options] [files]\n\n" \
|
97
|
+
"Prints out all lines for a Rails request where one line in that request " \
|
98
|
+
"matches the passed search string."
|
99
|
+
|
100
|
+
# Separator just adds a new line with the specified text.
|
101
|
+
options.separator ""
|
102
|
+
options.separator "Specific options:"
|
103
|
+
|
104
|
+
options.on("-i", "Perform case insensitive matching. By default, ralose is case sensitive.") do |be_case_insensitive|
|
105
|
+
@case_insensitive = be_case_insensitive
|
106
|
+
end
|
107
|
+
|
108
|
+
options.on("--no-color", "Disable colorized output") do |use_color|
|
109
|
+
@colorized_output = use_color
|
110
|
+
end
|
111
|
+
|
112
|
+
# on_tail says that this option should appear at the bottom of
|
113
|
+
# the options list.
|
114
|
+
options.on_tail("-h", "--help", "You're looking at it!") do
|
115
|
+
$stderr.puts options
|
116
|
+
exit 1
|
117
|
+
end
|
118
|
+
end.parse!
|
119
|
+
end
|
120
|
+
|
121
|
+
end
|
122
|
+
end
|
data/ralose.gemspec
ADDED
@@ -0,0 +1,57 @@
|
|
1
|
+
# Generated by jeweler
|
2
|
+
# DO NOT EDIT THIS FILE DIRECTLY
|
3
|
+
# Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
|
4
|
+
# -*- encoding: utf-8 -*-
|
5
|
+
# stub: ralose 0.1.0 ruby lib
|
6
|
+
|
7
|
+
Gem::Specification.new do |s|
|
8
|
+
s.name = "ralose".freeze
|
9
|
+
s.version = "0.1.0"
|
10
|
+
|
11
|
+
s.required_rubygems_version = Gem::Requirement.new(">= 0".freeze) if s.respond_to? :required_rubygems_version=
|
12
|
+
s.require_paths = ["lib".freeze]
|
13
|
+
s.authors = ["Douglas F Shearer".freeze]
|
14
|
+
s.date = "2018-05-25"
|
15
|
+
s.email = "dougal.s@gmail.com".freeze
|
16
|
+
s.executables = ["ralose".freeze]
|
17
|
+
s.extra_rdoc_files = [
|
18
|
+
"LICENSE.txt",
|
19
|
+
"README.rdoc"
|
20
|
+
]
|
21
|
+
s.files = [
|
22
|
+
".document",
|
23
|
+
"Gemfile",
|
24
|
+
"Gemfile.lock",
|
25
|
+
"LICENSE.txt",
|
26
|
+
"README.rdoc",
|
27
|
+
"Rakefile",
|
28
|
+
"VERSION",
|
29
|
+
"bin/ralose",
|
30
|
+
"lib/ralose.rb",
|
31
|
+
"lib/ralose/command.rb",
|
32
|
+
"ralose.gemspec",
|
33
|
+
"test/fixtures/sample.log",
|
34
|
+
"test/helper.rb",
|
35
|
+
"test/test_ralose.rb"
|
36
|
+
]
|
37
|
+
s.homepage = "http://github.com/dougal/ralose".freeze
|
38
|
+
s.licenses = ["MIT".freeze]
|
39
|
+
s.rubygems_version = "2.7.6".freeze
|
40
|
+
s.summary = "Search Rails logs for a string - get all the log lines for matching requests.".freeze
|
41
|
+
|
42
|
+
if s.respond_to? :specification_version then
|
43
|
+
s.specification_version = 4
|
44
|
+
|
45
|
+
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
46
|
+
s.add_development_dependency(%q<rdoc>.freeze, ["~> 6.0.4"])
|
47
|
+
s.add_development_dependency(%q<jeweler>.freeze, ["~> 2.3.1"])
|
48
|
+
else
|
49
|
+
s.add_dependency(%q<rdoc>.freeze, ["~> 6.0.4"])
|
50
|
+
s.add_dependency(%q<jeweler>.freeze, ["~> 2.3.1"])
|
51
|
+
end
|
52
|
+
else
|
53
|
+
s.add_dependency(%q<rdoc>.freeze, ["~> 6.0.4"])
|
54
|
+
s.add_dependency(%q<jeweler>.freeze, ["~> 2.3.1"])
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
@@ -0,0 +1,29 @@
|
|
1
|
+
[c61f4934-2c2a-4042-933d-3ded6b5980f4] Started GET "/blog_posts/1" for 127.0.0.1 at 2018-05-25 11:36:33 +0100
|
2
|
+
[c61f4934-2c2a-4042-933d-3ded6b5980f4] Processing by BlogPostsController#show as HTML
|
3
|
+
[c61f4934-2c2a-4042-933d-3ded6b5980f4] Parameters: {"id"=>"1"}
|
4
|
+
[c61f4934-2c2a-4042-933d-3ded6b5980f4] [1m[36mBlogPost Load (0.2ms)[0m [1m[34mSELECT "blog_posts".* FROM "blog_posts" WHERE "blog_posts"."id" = ? LIMIT ?[0m [["id", 1], ["LIMIT", 1]]
|
5
|
+
[c61f4934-2c2a-4042-933d-3ded6b5980f4] ↳ app/controllers/blog_posts_controller.rb:67
|
6
|
+
[c61f4934-2c2a-4042-933d-3ded6b5980f4] Rendering blog_posts/show.html.erb within layouts/application
|
7
|
+
[c61f4934-2c2a-4042-933d-3ded6b5980f4] Rendered blog_posts/show.html.erb within layouts/application (0.6ms)
|
8
|
+
[c61f4934-2c2a-4042-933d-3ded6b5980f4] Completed 200 OK in 31ms (Views: 25.0ms | ActiveRecord: 0.2ms)
|
9
|
+
|
10
|
+
|
11
|
+
[308be32b-a755-4e92-b3c0-ee330fe41f4a] Started PATCH "/blog_posts/2" for 127.0.0.1 at 2018-05-25 11:36:56 +0100
|
12
|
+
[308be32b-a755-4e92-b3c0-ee330fe41f4a] Processing by BlogPostsController#update as HTML
|
13
|
+
[308be32b-a755-4e92-b3c0-ee330fe41f4a] Parameters: {"utf8"=>"✓", "authenticity_token"=>"ddDPHZ9Rut2ARDVgYs+WcoVehTsgRMQduU1B6YbkztSfKM6nLqTMcWnf3PJ1E10SVGk0HAFjrBI5BhSTxepJJA==", "blog_post"=>{"title"=>"Another blog post", "body"=>"Sorry it has been so long since the last update.\r\n"}, "commit"=>"Update Blog post", "id"=>"2"}
|
14
|
+
[308be32b-a755-4e92-b3c0-ee330fe41f4a] [1m[36mBlogPost Load (0.2ms)[0m [1m[34mSELECT "blog_posts".* FROM "blog_posts" WHERE "blog_posts"."id" = ? LIMIT ?[0m [["id", 2], ["LIMIT", 1]]
|
15
|
+
[308be32b-a755-4e92-b3c0-ee330fe41f4a] ↳ app/controllers/blog_posts_controller.rb:67
|
16
|
+
[308be32b-a755-4e92-b3c0-ee330fe41f4a] [1m[35m (0.1ms)[0m [1m[36mbegin transaction[0m
|
17
|
+
[308be32b-a755-4e92-b3c0-ee330fe41f4a] ↳ app/controllers/blog_posts_controller.rb:44
|
18
|
+
[308be32b-a755-4e92-b3c0-ee330fe41f4a] [1m[36mBlogPost Update (0.4ms)[0m [1m[33mUPDATE "blog_posts" SET "body" = ?, "updated_at" = ? WHERE "blog_posts"."id" = ?[0m [["body", "Sorry it has been so long since the last update.\r\n"], ["updated_at", "2018-05-25 10:36:56.496279"], ["id", 2]]
|
19
|
+
[308be32b-a755-4e92-b3c0-ee330fe41f4a] ↳ app/controllers/blog_posts_controller.rb:44
|
20
|
+
[308be32b-a755-4e92-b3c0-ee330fe41f4a] [1m[35m (0.8ms)[0m [1m[36mcommit transaction[0m
|
21
|
+
[308be32b-a755-4e92-b3c0-ee330fe41f4a] ↳ app/controllers/blog_posts_controller.rb:44
|
22
|
+
[308be32b-a755-4e92-b3c0-ee330fe41f4a] Redirected to http://localhost:3000/blog_posts/2
|
23
|
+
[308be32b-a755-4e92-b3c0-ee330fe41f4a] Completed 302 Found in 7ms (ActiveRecord: 1.5ms)
|
24
|
+
|
25
|
+
|
26
|
+
[c2f8231f-feae-4b03-9315-2783d03ae2d0] Started GET "/blog_posts/2" for 127.0.0.1 at 2018-05-25 11:36:56 +0100
|
27
|
+
|
28
|
+
|
29
|
+
[8f5f0e4b-4951-601d-9692-7717bf536684] something and something
|
data/test/helper.rb
ADDED
@@ -0,0 +1,18 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'bundler'
|
3
|
+
|
4
|
+
begin
|
5
|
+
Bundler.setup(:default, :development, :xzibit)
|
6
|
+
rescue Bundler::BundlerError => e
|
7
|
+
$stderr.puts e.message
|
8
|
+
$stderr.puts "Run `bundle install` to install missing gems"
|
9
|
+
exit e.status_code
|
10
|
+
end
|
11
|
+
require 'test/unit'
|
12
|
+
|
13
|
+
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
|
14
|
+
$LOAD_PATH.unshift(File.dirname(__FILE__))
|
15
|
+
require 'ralose'
|
16
|
+
|
17
|
+
class Test::Unit::TestCase
|
18
|
+
end
|
data/test/test_ralose.rb
ADDED
@@ -0,0 +1,56 @@
|
|
1
|
+
require 'helper'
|
2
|
+
|
3
|
+
class TestRaLoSe < Test::Unit::TestCase
|
4
|
+
|
5
|
+
def test_returns_no_lines_when_passed_a_file
|
6
|
+
query = 'nothing to see here'
|
7
|
+
output = `bundle exec ralose '#{query}' test/fixtures/sample.log`
|
8
|
+
|
9
|
+
expected_output = %{}
|
10
|
+
assert_equal expected_output, output
|
11
|
+
end
|
12
|
+
|
13
|
+
def test_returns_no_lines_when_piped_a_file
|
14
|
+
query = 'nothing to see here'
|
15
|
+
output = `cat test/fixtures/sample.log | bundle exec ralose '#{query}'`
|
16
|
+
|
17
|
+
expected_output = %{}
|
18
|
+
assert_equal expected_output, output
|
19
|
+
end
|
20
|
+
|
21
|
+
def test_returns_the_matching_request_when_passed_a_file
|
22
|
+
query = 'GET "/blog_posts/1"'
|
23
|
+
output = `bundle exec ralose '#{query}' test/fixtures/sample.log`
|
24
|
+
|
25
|
+
expected_output = %{[c61f4934-2c2a-4042-933d-3ded6b5980f4] Started \e[31mGET "/blog_posts/1"\e[0m for 127.0.0.1 at 2018-05-25 11:36:33 +0100\n[c61f4934-2c2a-4042-933d-3ded6b5980f4] Processing by BlogPostsController#show as HTML\n[c61f4934-2c2a-4042-933d-3ded6b5980f4] Parameters: {"id"=>"1"}\n[c61f4934-2c2a-4042-933d-3ded6b5980f4] \e[1m\e[36mBlogPost Load (0.2ms)\e[0m \e[1m\e[34mSELECT "blog_posts".* FROM "blog_posts" WHERE "blog_posts"."id" = ? LIMIT ?\e[0m [["id", 1], ["LIMIT", 1]]\n[c61f4934-2c2a-4042-933d-3ded6b5980f4] ↳ app/controllers/blog_posts_controller.rb:67\n[c61f4934-2c2a-4042-933d-3ded6b5980f4] Rendering blog_posts/show.html.erb within layouts/application\n[c61f4934-2c2a-4042-933d-3ded6b5980f4] Rendered blog_posts/show.html.erb within layouts/application (0.6ms)\n[c61f4934-2c2a-4042-933d-3ded6b5980f4] Completed 200 OK in 31ms (Views: 25.0ms | ActiveRecord: 0.2ms)\n\n\n}
|
26
|
+
assert_equal expected_output, output
|
27
|
+
end
|
28
|
+
|
29
|
+
def test_returns_the_matching_request_when_piped_a_file
|
30
|
+
query = 'GET "/blog_posts/1"'
|
31
|
+
output = `cat test/fixtures/sample.log | bundle exec ralose '#{query}'`
|
32
|
+
|
33
|
+
expected_output = %{[c61f4934-2c2a-4042-933d-3ded6b5980f4] Started \e[31mGET "/blog_posts/1"\e[0m for 127.0.0.1 at 2018-05-25 11:36:33 +0100\n[c61f4934-2c2a-4042-933d-3ded6b5980f4] Processing by BlogPostsController#show as HTML\n[c61f4934-2c2a-4042-933d-3ded6b5980f4] Parameters: {"id"=>"1"}\n[c61f4934-2c2a-4042-933d-3ded6b5980f4] \e[1m\e[36mBlogPost Load (0.2ms)\e[0m \e[1m\e[34mSELECT "blog_posts".* FROM "blog_posts" WHERE "blog_posts"."id" = ? LIMIT ?\e[0m [["id", 1], ["LIMIT", 1]]\n[c61f4934-2c2a-4042-933d-3ded6b5980f4] ↳ app/controllers/blog_posts_controller.rb:67\n[c61f4934-2c2a-4042-933d-3ded6b5980f4] Rendering blog_posts/show.html.erb within layouts/application\n[c61f4934-2c2a-4042-933d-3ded6b5980f4] Rendered blog_posts/show.html.erb within layouts/application (0.6ms)\n[c61f4934-2c2a-4042-933d-3ded6b5980f4] Completed 200 OK in 31ms (Views: 25.0ms | ActiveRecord: 0.2ms)\n\n\n}
|
34
|
+
assert_equal expected_output, output
|
35
|
+
end
|
36
|
+
|
37
|
+
def test_colors_the_matching_string
|
38
|
+
query = 'something'
|
39
|
+
output = `bundle exec ralose '#{query}' test/fixtures/sample.log`
|
40
|
+
|
41
|
+
expected_output = %{\e[31msomething\e[0m and \e[31msomething\e[0m}
|
42
|
+
assert output.include?(expected_output)
|
43
|
+
end
|
44
|
+
|
45
|
+
def test_does_not_color_the_matching_string
|
46
|
+
query = 'something'
|
47
|
+
output = `bundle exec ralose --no-color '#{query}' test/fixtures/sample.log`
|
48
|
+
|
49
|
+
unexpected_output = %{\e[31msomething\e[0m and \e[31msomething\e[0m}
|
50
|
+
expected_output = %{something and something}
|
51
|
+
|
52
|
+
assert output.include?(expected_output)
|
53
|
+
assert !output.include?(unexpected_output)
|
54
|
+
end
|
55
|
+
|
56
|
+
end
|
metadata
ADDED
@@ -0,0 +1,88 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: ralose
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Douglas F Shearer
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2018-05-25 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: rdoc
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: 6.0.4
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: 6.0.4
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: jeweler
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: 2.3.1
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: 2.3.1
|
41
|
+
description:
|
42
|
+
email: dougal.s@gmail.com
|
43
|
+
executables:
|
44
|
+
- ralose
|
45
|
+
extensions: []
|
46
|
+
extra_rdoc_files:
|
47
|
+
- LICENSE.txt
|
48
|
+
- README.rdoc
|
49
|
+
files:
|
50
|
+
- ".document"
|
51
|
+
- Gemfile
|
52
|
+
- Gemfile.lock
|
53
|
+
- LICENSE.txt
|
54
|
+
- README.rdoc
|
55
|
+
- Rakefile
|
56
|
+
- VERSION
|
57
|
+
- bin/ralose
|
58
|
+
- lib/ralose.rb
|
59
|
+
- lib/ralose/command.rb
|
60
|
+
- ralose.gemspec
|
61
|
+
- test/fixtures/sample.log
|
62
|
+
- test/helper.rb
|
63
|
+
- test/test_ralose.rb
|
64
|
+
homepage: http://github.com/dougal/ralose
|
65
|
+
licenses:
|
66
|
+
- MIT
|
67
|
+
metadata: {}
|
68
|
+
post_install_message:
|
69
|
+
rdoc_options: []
|
70
|
+
require_paths:
|
71
|
+
- lib
|
72
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
73
|
+
requirements:
|
74
|
+
- - ">="
|
75
|
+
- !ruby/object:Gem::Version
|
76
|
+
version: '0'
|
77
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
78
|
+
requirements:
|
79
|
+
- - ">="
|
80
|
+
- !ruby/object:Gem::Version
|
81
|
+
version: '0'
|
82
|
+
requirements: []
|
83
|
+
rubyforge_project:
|
84
|
+
rubygems_version: 2.7.6
|
85
|
+
signing_key:
|
86
|
+
specification_version: 4
|
87
|
+
summary: Search Rails logs for a string - get all the log lines for matching requests.
|
88
|
+
test_files: []
|