clarity 0.9.5 → 0.9.7
Sign up to get free protection for your applications and to get access to all the features.
- data.tar.gz.sig +0 -0
- data/Manifest.txt +2 -5
- data/README.rdoc +18 -2
- data/Rakefile +5 -3
- data/lib/clarity.rb +3 -5
- data/lib/clarity/cli.rb +8 -8
- data/lib/clarity/commands/{command_builder.rb → grep_command_builder.rb} +1 -1
- data/lib/clarity/commands/tail_command_builder.rb +1 -1
- data/lib/clarity/renderers/log_renderer.rb +1 -1
- data/lib/clarity/server.rb +6 -4
- data/test/commands/{command_builder_test.rb → grep_command_builder_test.rb} +17 -17
- data/test/commands/tail_command_builder_test.rb +1 -1
- data/views/_toolbar.html.erb +3 -29
- metadata +41 -16
- metadata.gz.sig +1 -0
- data/test/parsers/hostname_parser_test.rb +0 -39
- data/test/parsers/shop_parser_test.rb +0 -53
- data/test/parsers/time_parser_test.rb +0 -83
data.tar.gz.sig
ADDED
Binary file
|
data/Manifest.txt
CHANGED
@@ -7,7 +7,7 @@ bin/clarity
|
|
7
7
|
config/config.yml.sample
|
8
8
|
lib/clarity.rb
|
9
9
|
lib/clarity/cli.rb
|
10
|
-
lib/clarity/commands/
|
10
|
+
lib/clarity/commands/grep_command_builder.rb
|
11
11
|
lib/clarity/commands/tail_command_builder.rb
|
12
12
|
lib/clarity/grep_renderer.rb
|
13
13
|
lib/clarity/process_tree.rb
|
@@ -22,12 +22,9 @@ public/stylesheets/app.css
|
|
22
22
|
script/console
|
23
23
|
script/destroy
|
24
24
|
script/generate
|
25
|
-
test/commands/
|
25
|
+
test/commands/grep_command_builder_test.rb
|
26
26
|
test/commands/tail_command_builder_test.rb
|
27
27
|
test/files/logfile.log
|
28
|
-
test/parsers/hostname_parser_test.rb
|
29
|
-
test/parsers/shop_parser_test.rb
|
30
|
-
test/parsers/time_parser_test.rb
|
31
28
|
test/test_helper.rb
|
32
29
|
test/test_string_scanner.rb
|
33
30
|
views/_header.html.erb
|
data/README.rdoc
CHANGED
@@ -8,8 +8,8 @@ Clarity - a log search tool
|
|
8
8
|
By John Tajima & Tobi Lütke
|
9
9
|
|
10
10
|
Clarity is a Splunk like web interface for your server log files. It supports
|
11
|
-
searching (using grep) as well as trailing log files. It has been written
|
12
|
-
the event based architecture based on EventMachine and so allows real-time search
|
11
|
+
searching (using grep) as well as trailing log files in realtime. It has been written
|
12
|
+
using the event based architecture based on EventMachine and so allows real-time search
|
13
13
|
of very large log files. If you hit the browser Stop button it will also kill
|
14
14
|
the grep / tail utility.
|
15
15
|
|
@@ -20,6 +20,21 @@ big success internally that we decided to release it as open source.
|
|
20
20
|
== USAGE:
|
21
21
|
|
22
22
|
clarity --username=admin --password=secret --port=8989 /var/log
|
23
|
+
|
24
|
+
== COMMANDLINE:
|
25
|
+
|
26
|
+
Specific options:
|
27
|
+
-f, --config=FILE Config file (yml)
|
28
|
+
-p, --port=PORT Port to listen on
|
29
|
+
-b, --address=ADDRESS Address to bind to (default 0.0.0.0)
|
30
|
+
--include=MASK File mask of logs to add (default: **/*.log*)
|
31
|
+
--user=USER User to run as
|
32
|
+
Password protection:
|
33
|
+
--username=USER Enable httpauth username
|
34
|
+
--password=PASS Enable httpauth password
|
35
|
+
Misc:
|
36
|
+
-h, --help Show this message.
|
37
|
+
|
23
38
|
|
24
39
|
== SCREENSHOT:
|
25
40
|
|
@@ -29,6 +44,7 @@ http://img.skitch.com/20091104-je9kq1a2gfr586ia8y246bq4n8.png
|
|
29
44
|
|
30
45
|
* eventmachine
|
31
46
|
* eventmachine_httpserver
|
47
|
+
* json
|
32
48
|
|
33
49
|
== INSTALL:
|
34
50
|
|
data/Rakefile
CHANGED
@@ -12,9 +12,11 @@ Hoe.plugin :newgem
|
|
12
12
|
$hoe = Hoe.spec 'clarity' do
|
13
13
|
self.developer 'Tobias Lütke', 'tobi@shopify.com'
|
14
14
|
self.developer 'John Tajima', 'john@shopify.com'
|
15
|
-
self.
|
16
|
-
self.
|
17
|
-
self.
|
15
|
+
self.summary = 'Web interface for grep and tail -f'
|
16
|
+
#self.post_install_message = 'PostInstall.txt'
|
17
|
+
self.readme_file = 'README.rdoc'
|
18
|
+
self.extra_deps = [['eventmachine','>= 0.12.10'], ['eventmachine_httpserver','>= 0.2.0'], ["json", ">= 1.0.0"]]
|
19
|
+
self.test_globs = ['test/**/*_test.rb']
|
18
20
|
end
|
19
21
|
|
20
22
|
require 'newgem/tasks'
|
data/lib/clarity.rb
CHANGED
@@ -2,18 +2,16 @@ $:.unshift(File.dirname(__FILE__)) unless $:.include?(File.dirname(__FILE__)) ||
|
|
2
2
|
|
3
3
|
require 'eventmachine'
|
4
4
|
require 'evma_httpserver'
|
5
|
+
require 'json'
|
5
6
|
require 'yaml'
|
6
7
|
require 'base64'
|
7
8
|
require 'clarity/server'
|
8
|
-
require 'clarity/commands/
|
9
|
+
require 'clarity/commands/grep_command_builder'
|
9
10
|
require 'clarity/commands/tail_command_builder'
|
10
|
-
require 'clarity/parsers/time_parser'
|
11
|
-
require 'clarity/parsers/hostname_parser'
|
12
|
-
require 'clarity/parsers/shop_parser'
|
13
11
|
require 'clarity/renderers/log_renderer'
|
14
12
|
|
15
13
|
module Clarity
|
16
|
-
VERSION = '0.9.
|
14
|
+
VERSION = '0.9.7'
|
17
15
|
|
18
16
|
Templates = File.dirname(__FILE__) + '/../views'
|
19
17
|
Public = File.dirname(__FILE__) + '/../public'
|
data/lib/clarity/cli.rb
CHANGED
@@ -69,18 +69,18 @@ module Clarity
|
|
69
69
|
|
70
70
|
begin
|
71
71
|
opts.parse!(arguments)
|
72
|
+
|
73
|
+
options[:log_files] ||= ['**/*.log*']
|
72
74
|
|
73
75
|
if arguments.first
|
74
76
|
Dir.chdir(arguments.first)
|
77
|
+
|
78
|
+
::Clarity::Server.run(options)
|
79
|
+
|
80
|
+
else
|
81
|
+
puts opts
|
82
|
+
exit(1)
|
75
83
|
end
|
76
|
-
|
77
|
-
options[:log_files] ||= ['**/*.log*']
|
78
|
-
|
79
|
-
::Clarity::Server.run(options)
|
80
|
-
|
81
|
-
#rescue
|
82
|
-
# puts opts
|
83
|
-
# exit
|
84
84
|
end
|
85
85
|
end
|
86
86
|
|
@@ -1,7 +1,7 @@
|
|
1
1
|
#
|
2
2
|
# Handles tailing of log files
|
3
3
|
#
|
4
|
-
class TailCommandBuilder <
|
4
|
+
class TailCommandBuilder < GrepCommandBuilder
|
5
5
|
|
6
6
|
def valid?
|
7
7
|
raise InvalidParameterError, "Log file parameter not supplied or invalid log file" unless filename && !filename.empty? && File.extname(filename) == ".log"
|
data/lib/clarity/server.rb
CHANGED
@@ -28,14 +28,16 @@ module Clarity
|
|
28
28
|
a.required_password = options[:password]
|
29
29
|
end
|
30
30
|
|
31
|
-
STDERR.puts "
|
31
|
+
STDERR.puts "Clarity #{Clarity::VERSION} starting up."
|
32
|
+
STDERR.puts " * listening on #{options[:address]}:#{options[:port]}"
|
32
33
|
|
33
34
|
if options[:user]
|
34
|
-
STDERR.puts "Running as user #{options[:user]}"
|
35
|
+
STDERR.puts " * Running as user #{options[:user]}"
|
35
36
|
EventMachine.set_effective_user(options[:user])
|
36
37
|
end
|
37
38
|
|
38
|
-
STDERR.puts "
|
39
|
+
STDERR.puts " * Log mask(s): #{options[:log_files].join(', ')}"
|
40
|
+
STDERR.puts
|
39
41
|
end
|
40
42
|
end
|
41
43
|
|
@@ -55,7 +57,7 @@ module Clarity
|
|
55
57
|
else
|
56
58
|
# get command
|
57
59
|
command = case params['tool']
|
58
|
-
when 'grep' then
|
60
|
+
when 'grep' then GrepCommandBuilder.new(params).command
|
59
61
|
when 'tail' then TailCommandBuilder.new(params).command
|
60
62
|
else raise InvalidParameterError, "Invalid Tool parameter"
|
61
63
|
end
|
@@ -1,6 +1,6 @@
|
|
1
1
|
require 'test_helper'
|
2
2
|
|
3
|
-
class
|
3
|
+
class GrepCommandBuilderTest < Test::Unit::TestCase
|
4
4
|
|
5
5
|
def setup
|
6
6
|
@params = {
|
@@ -10,29 +10,29 @@ class CommandBuilderTest < Test::Unit::TestCase
|
|
10
10
|
"term2" => nil,
|
11
11
|
"term3" => nil
|
12
12
|
}
|
13
|
-
@command =
|
13
|
+
@command = GrepCommandBuilder.new(@params)
|
14
14
|
end
|
15
15
|
|
16
16
|
def test_create_new_builder
|
17
|
-
assert @command.is_a?(
|
17
|
+
assert @command.is_a?(GrepCommandBuilder)
|
18
18
|
assert_equal "testfile.log", @command.filename
|
19
19
|
assert_equal 1, @command.terms.size
|
20
20
|
end
|
21
21
|
|
22
22
|
def test_raises_error_if_no_file
|
23
|
-
assert_raises
|
24
|
-
command =
|
23
|
+
assert_raises GrepCommandBuilder::InvalidParameterError do
|
24
|
+
command = GrepCommandBuilder.new(@params.merge("file" => nil))
|
25
25
|
end
|
26
26
|
end
|
27
27
|
|
28
28
|
def test_exec_functions_for_log
|
29
|
-
command =
|
29
|
+
command = GrepCommandBuilder.new(@params)
|
30
30
|
assert_equal 1, command.exec_functions.size
|
31
31
|
assert_match(/^grep/, command.exec_functions.first)
|
32
32
|
end
|
33
33
|
|
34
34
|
def test_exec_functions_with_multiple_terms_for_log
|
35
|
-
command =
|
35
|
+
command = GrepCommandBuilder.new(@params.merge("term2" => "bar", "term3" => "baz"))
|
36
36
|
assert_equal 3, command.exec_functions.size
|
37
37
|
assert_match(/^grep/, command.exec_functions[0])
|
38
38
|
assert_match(/^grep/, command.exec_functions[1])
|
@@ -40,19 +40,19 @@ class CommandBuilderTest < Test::Unit::TestCase
|
|
40
40
|
end
|
41
41
|
|
42
42
|
def test_exec_function_with_no_terms_for_log
|
43
|
-
command =
|
43
|
+
command = GrepCommandBuilder.new(@params.merge("term1" => nil))
|
44
44
|
assert_equal 1, command.exec_functions.size
|
45
45
|
assert_match(/^cat/, command.exec_functions[0])
|
46
46
|
end
|
47
47
|
|
48
48
|
def test_exec_funcations_for_gzip
|
49
|
-
command =
|
49
|
+
command = GrepCommandBuilder.new(@params.merge("file" => "testfile.gz"))
|
50
50
|
assert_equal 1, command.exec_functions.size
|
51
51
|
assert_match(/^zgrep/, command.exec_functions.first)
|
52
52
|
end
|
53
53
|
|
54
54
|
def test_exec_functions_with_multiple_terms_for_gzip
|
55
|
-
command =
|
55
|
+
command = GrepCommandBuilder.new(@params.merge("file" => "testfile.gz", "term2" => "bar", "term3" => "baz"))
|
56
56
|
assert_equal 3, command.exec_functions.size
|
57
57
|
assert_match(/^zgrep/, command.exec_functions[0])
|
58
58
|
assert_match(/^grep/, command.exec_functions[1])
|
@@ -60,38 +60,38 @@ class CommandBuilderTest < Test::Unit::TestCase
|
|
60
60
|
end
|
61
61
|
|
62
62
|
def test_exec_function_with_no_terms_for_gzip
|
63
|
-
command =
|
63
|
+
command = GrepCommandBuilder.new(@params.merge("file" => "testfile.gz", "term1" => nil))
|
64
64
|
assert_equal 1, command.exec_functions.size
|
65
65
|
assert_match "gzcat", command.exec_functions[0]
|
66
66
|
end
|
67
67
|
|
68
68
|
def test_command_for_log
|
69
|
-
command =
|
69
|
+
command = GrepCommandBuilder.new(@params)
|
70
70
|
assert_equal "sh -c 'grep -e foo testfile.log'", command.command
|
71
71
|
end
|
72
72
|
|
73
73
|
def test_command_with_no_terms_for_log
|
74
|
-
command =
|
74
|
+
command = GrepCommandBuilder.new(@params.merge("term1" => nil))
|
75
75
|
assert_equal "sh -c 'cat testfile.log'", command.command
|
76
76
|
end
|
77
77
|
|
78
78
|
def test_command_with_multiple_terms_for_log
|
79
|
-
command =
|
79
|
+
command = GrepCommandBuilder.new(@params.merge("term2" => "bar", "term3" => "baz"))
|
80
80
|
assert_equal "sh -c 'grep -e foo testfile.log | grep -e bar | grep -e baz'", command.command
|
81
81
|
end
|
82
82
|
|
83
83
|
def test_command_for_gzip
|
84
|
-
command =
|
84
|
+
command = GrepCommandBuilder.new(@params.merge("file" => "testfile.gz"))
|
85
85
|
assert_equal "sh -c 'zgrep -e foo testfile.gz'", command.command
|
86
86
|
end
|
87
87
|
|
88
88
|
def test_command_with_no_terms_for_gzip
|
89
|
-
command =
|
89
|
+
command = GrepCommandBuilder.new(@params.merge("file" => "testfile.gz","term1" => nil))
|
90
90
|
assert_equal "sh -c 'gzcat testfile.gz'", command.command
|
91
91
|
end
|
92
92
|
|
93
93
|
def test_command_with_multiple_terms_for_gzip
|
94
|
-
command =
|
94
|
+
command = GrepCommandBuilder.new(@params.merge("file" => "testfile.gz","term2" => "bar", "term3" => "baz"))
|
95
95
|
assert_equal "sh -c 'zgrep -e foo testfile.gz | grep -e bar | grep -e baz'", command.command
|
96
96
|
end
|
97
97
|
|
@@ -20,7 +20,7 @@ class TailCommandBuilderTest < Test::Unit::TestCase
|
|
20
20
|
end
|
21
21
|
|
22
22
|
def test_raises_error_if_invalid_file
|
23
|
-
assert_raises
|
23
|
+
assert_raises GrepCommandBuilder::InvalidParameterError do
|
24
24
|
command = TailCommandBuilder.new(@params.merge("file" => "testfile.gz"))
|
25
25
|
end
|
26
26
|
end
|
data/views/_toolbar.html.erb
CHANGED
@@ -43,32 +43,6 @@
|
|
43
43
|
<td>
|
44
44
|
</td>
|
45
45
|
</tr>
|
46
|
-
<tr id='advanced-options'>
|
47
|
-
<td></td>
|
48
|
-
<td>
|
49
|
-
<span class='small'>
|
50
|
-
<a href="#" id="enable-advanced" onclick="Search.showAdvanced(); return false;">Enable Advanced Options</a>
|
51
|
-
<a href="#" id="disable-advanced" onclick="Search.hideAdvanced(); return false;" style='display:none'>Disable Advanced Options</a>
|
52
|
-
</span>
|
53
|
-
</td>
|
54
|
-
<td colspan=2 id='start-time' class='advanced-options' style='display:none'>
|
55
|
-
<span class='small'>Start Time</span>
|
56
|
-
<input type='text' name='sh' class='time' id='sh'> :
|
57
|
-
<input type='text' name='sm' class='time' id='sm'> :
|
58
|
-
<input type='text' name='ss' class='time' id='ss'>
|
59
|
-
</td>
|
60
|
-
<td colspan=2 id='end-time' class='advanced-options' style='display:none'>
|
61
|
-
<span class='small'>End Time</span>
|
62
|
-
<input type='text' name='eh' class='time' id='eh'> :
|
63
|
-
<input type='text' name='em' class='time' id='em'> :
|
64
|
-
<input type='text' name='es' class='time' id='es'>
|
65
|
-
</td>
|
66
|
-
<td class='advanced-options' style='display:none'>
|
67
|
-
<span class="small">
|
68
|
-
<a href="#" onclick="Search.clearAdvanced();return false">clear advanced</a>
|
69
|
-
</span>
|
70
|
-
</td>
|
71
|
-
</tr>
|
72
46
|
</table>
|
73
47
|
</form>
|
74
48
|
</div>
|
@@ -81,9 +55,9 @@
|
|
81
55
|
</div>
|
82
56
|
|
83
57
|
<script>
|
84
|
-
Search.init({ 'grep': <%= logfiles.map {|f| f }.
|
85
|
-
'tail': <%= logfiles.map {|f| f if f =~ /log$/ }.compact.
|
86
|
-
<%= params.empty? ? 'null' : params.
|
58
|
+
Search.init({ 'grep': <%= logfiles.map {|f| f }.to_json %>,
|
59
|
+
'tail': <%= logfiles.map {|f| f if f =~ /log$/ }.compact.to_json %> },
|
60
|
+
<%= params.empty? ? 'null' : params.to_json %> );
|
87
61
|
|
88
62
|
|
89
63
|
</script>
|
metadata
CHANGED
@@ -1,16 +1,37 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: clarity
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.9.
|
4
|
+
version: 0.9.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- "Tobias L\xC3\xBCtke"
|
8
8
|
- John Tajima
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
|
-
cert_chain:
|
11
|
+
cert_chain:
|
12
|
+
- |
|
13
|
+
-----BEGIN CERTIFICATE-----
|
14
|
+
MIIDMDCCAhigAwIBAgIBADANBgkqhkiG9w0BAQUFADA+MQ0wCwYDVQQDDAR0b2Jp
|
15
|
+
MRgwFgYKCZImiZPyLGQBGRYIbGVldHNvZnQxEzARBgoJkiaJk/IsZAEZFgNjb20w
|
16
|
+
HhcNMDkwNjA4MDAyMjE2WhcNMTAwNjA4MDAyMjE2WjA+MQ0wCwYDVQQDDAR0b2Jp
|
17
|
+
MRgwFgYKCZImiZPyLGQBGRYIbGVldHNvZnQxEzARBgoJkiaJk/IsZAEZFgNjb20w
|
18
|
+
ggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQC9eY669CSPwqcWqdZR28wy
|
19
|
+
LE6lF1RRS9KX2MEwiQML81UiY/yXz53Z082ISzUEcfzMUfVBwBO7y3NJF2th1/zt
|
20
|
+
MoEl24Me7ToU1wYfH0TOO6+gT++FmQyaGSuXWgXxEXyvnOP3k2wJ3IIgHvF8AUyW
|
21
|
+
i8GKFJKDmV/crocqOKu0A82Ugz0QGJbH+3gRk/BG926VffQUwQhcMV3c8+IWh/Ye
|
22
|
+
mx5mc1Wtykj945+G3XuCQFHcOUi4JKfDp5i/tce39ePNiXk74sn7X04O8aPrYRju
|
23
|
+
TPJC7yuwM1vOiR2yKutB+cjIG8srZiKN5IgqyECviHIpAOy7nDK5L5CexOYWEFxj
|
24
|
+
AgMBAAGjOTA3MAkGA1UdEwQCMAAwCwYDVR0PBAQDAgSwMB0GA1UdDgQWBBQkWqDl
|
25
|
+
Oe9BDb/KLIhD4wMtnv8zkDANBgkqhkiG9w0BAQUFAAOCAQEAA6xfeq0PIZtUoz5i
|
26
|
+
Kr2bYQqgongNY/Mw4NMWN7cYYmIh1BUjWDnuOVffC3w3vnsUGOUUPeeBtQye4Dyy
|
27
|
+
zleZjlzOiOA4vFOnItldoElAo+gc5xoEmiE/P8AnCaIHEdgroeW+bZj3U3ReY7iu
|
28
|
+
z6rSwN5jLOnP2BmCdP/AgbAV3rW7hhgaz6nGx7O4hehQ/F1SbYhl115B6RpYF+tN
|
29
|
+
p9h9ap2kONwGQwBlo6oGQmuatzbfiVQRxhDj7JzyNaYQM4DR0+4vbu59vYFVSFHf
|
30
|
+
oz7Ippbls3jwI136whTuoiGZi/LDBc1Hw6iw99GGDR0vDGCLmPHyiJLfD6TbzzNo
|
31
|
+
oB0pMQ==
|
32
|
+
-----END CERTIFICATE-----
|
12
33
|
|
13
|
-
date: 2009-12-
|
34
|
+
date: 2009-12-05 00:00:00 -05:00
|
14
35
|
default_executable:
|
15
36
|
dependencies:
|
16
37
|
- !ruby/object:Gem::Dependency
|
@@ -33,6 +54,16 @@ dependencies:
|
|
33
54
|
- !ruby/object:Gem::Version
|
34
55
|
version: 0.2.0
|
35
56
|
version:
|
57
|
+
- !ruby/object:Gem::Dependency
|
58
|
+
name: json
|
59
|
+
type: :runtime
|
60
|
+
version_requirement:
|
61
|
+
version_requirements: !ruby/object:Gem::Requirement
|
62
|
+
requirements:
|
63
|
+
- - ">="
|
64
|
+
- !ruby/object:Gem::Version
|
65
|
+
version: 1.0.0
|
66
|
+
version:
|
36
67
|
- !ruby/object:Gem::Dependency
|
37
68
|
name: hoe
|
38
69
|
type: :development
|
@@ -46,8 +77,8 @@ dependencies:
|
|
46
77
|
description: "Clarity - a log search tool\n\
|
47
78
|
By John Tajima & Tobi L\xC3\xBCtke\n\n\
|
48
79
|
Clarity is a Splunk like web interface for your server log files. It supports \n\
|
49
|
-
searching (using grep) as well as trailing log files. It has been written
|
50
|
-
the event based architecture based on EventMachine and so allows real-time search\n\
|
80
|
+
searching (using grep) as well as trailing log files in realtime. It has been written \n\
|
81
|
+
using the event based architecture based on EventMachine and so allows real-time search\n\
|
51
82
|
of very large log files. If you hit the browser Stop button it will also kill \n\
|
52
83
|
the grep / tail utility. \n\n\
|
53
84
|
We wrote Clarity to allow our support staff to use a simple interface to look\n\
|
@@ -74,7 +105,7 @@ files:
|
|
74
105
|
- config/config.yml.sample
|
75
106
|
- lib/clarity.rb
|
76
107
|
- lib/clarity/cli.rb
|
77
|
-
- lib/clarity/commands/
|
108
|
+
- lib/clarity/commands/grep_command_builder.rb
|
78
109
|
- lib/clarity/commands/tail_command_builder.rb
|
79
110
|
- lib/clarity/grep_renderer.rb
|
80
111
|
- lib/clarity/process_tree.rb
|
@@ -89,12 +120,9 @@ files:
|
|
89
120
|
- script/console
|
90
121
|
- script/destroy
|
91
122
|
- script/generate
|
92
|
-
- test/commands/
|
123
|
+
- test/commands/grep_command_builder_test.rb
|
93
124
|
- test/commands/tail_command_builder_test.rb
|
94
125
|
- test/files/logfile.log
|
95
|
-
- test/parsers/hostname_parser_test.rb
|
96
|
-
- test/parsers/shop_parser_test.rb
|
97
|
-
- test/parsers/time_parser_test.rb
|
98
126
|
- test/test_helper.rb
|
99
127
|
- test/test_string_scanner.rb
|
100
128
|
- views/_header.html.erb
|
@@ -105,7 +133,7 @@ has_rdoc: true
|
|
105
133
|
homepage: http://github.com/tobi/clarity
|
106
134
|
licenses: []
|
107
135
|
|
108
|
-
post_install_message:
|
136
|
+
post_install_message:
|
109
137
|
rdoc_options:
|
110
138
|
- --main
|
111
139
|
- README.rdoc
|
@@ -129,10 +157,7 @@ rubyforge_project: clarity
|
|
129
157
|
rubygems_version: 1.3.5
|
130
158
|
signing_key:
|
131
159
|
specification_version: 3
|
132
|
-
summary:
|
160
|
+
summary: Web interface for grep and tail -f
|
133
161
|
test_files:
|
134
|
-
- test/commands/
|
162
|
+
- test/commands/grep_command_builder_test.rb
|
135
163
|
- test/commands/tail_command_builder_test.rb
|
136
|
-
- test/parsers/hostname_parser_test.rb
|
137
|
-
- test/parsers/shop_parser_test.rb
|
138
|
-
- test/parsers/time_parser_test.rb
|
metadata.gz.sig
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
�#�3��koh���P k0�����u�*ضC�8E��o�tLZJҩ%PՌBh]��C��|8�a�/�LA0�t��\���ơ�HBR~�����Ii֖4#P�t��hw��';�:���Q��ͭz�n�9��jn��\��k��3��:7��&/ޛ 䤆�ވ?d�np��07�F C��;�<���h��Vٟ����Yq��|�vC�<#9��T�\j�����N�����G<��.eCaN�o�ޏ
|
@@ -1,39 +0,0 @@
|
|
1
|
-
require 'test_helper'
|
2
|
-
|
3
|
-
class HostnameParserTest < Test::Unit::TestCase
|
4
|
-
|
5
|
-
def setup
|
6
|
-
@params = { "sh" => "12", "sm" => "00", "ss" => "10", "eh" => "12", "em" => "00", "es" => "59" }
|
7
|
-
@lines = %|Jul 24 14:58:21 app3 rails.shopify[9855]: [wadedemt.myshopify.com] Processing ShopController#products (for 192.168.1.230 at 2009-07-24 14:58:21) [GET]
|
8
|
-
Jul 24 12:00:21 192.168.5.1 rails.shopify[9855]: [wadedemt.myshopify.com] Processing ShopController#products (for 192.168.1.230 at 2009-07-24 14:58:21) [GET]
|
9
|
-
Jul 24 12:00:31 192.168.5.1 rails.shopify[9855]: [test.myshopify.com] Processing ShopController#products (for 192.168.1.230 at 2009-07-24 14:58:21) [GET]
|
10
|
-
Jul 24 12:00:41 192.168.5.1 rails.shopify[9855]: [test2.myshopify.com] Processing some other line of text
|
11
|
-
|.split("\n")
|
12
|
-
@parser = HostnameParser.new(nil)
|
13
|
-
end
|
14
|
-
|
15
|
-
|
16
|
-
def test_parse_strips_out_ip_and_appname
|
17
|
-
line = @lines[1][16..-1] # strip out first 16 lines
|
18
|
-
out = @parser.parse(line)
|
19
|
-
|
20
|
-
assert out.has_key?(:line)
|
21
|
-
assert_equal "[wadedemt.myshopify.com] Processing ShopController#products (for 192.168.1.230 at 2009-07-24 14:58:21) [GET]", out[:line]
|
22
|
-
end
|
23
|
-
|
24
|
-
def test_parse_strips_out_host_and_appname
|
25
|
-
line = @lines.first[16..-1] # strip out first 16 lines
|
26
|
-
out = @parser.parse(line)
|
27
|
-
|
28
|
-
assert out.has_key?(:line)
|
29
|
-
assert_equal "[wadedemt.myshopify.com] Processing ShopController#products (for 192.168.1.230 at 2009-07-24 14:58:21) [GET]", out[:line]
|
30
|
-
end
|
31
|
-
|
32
|
-
def test_parse_returns_line_if_no_match
|
33
|
-
line = "in@valid rails.shopify[9855]: [wadedemt.myshopify.com] Processing ShopController#products (for 192.168.1.230 at 2009-07-24 14:58:21) [GET]"
|
34
|
-
out = @parser.parse(line)
|
35
|
-
assert out.has_key?(:line)
|
36
|
-
assert_equal line, out[:line]
|
37
|
-
end
|
38
|
-
|
39
|
-
end
|
@@ -1,53 +0,0 @@
|
|
1
|
-
require 'test_helper'
|
2
|
-
|
3
|
-
class ShopParserTest < Test::Unit::TestCase
|
4
|
-
|
5
|
-
def setup
|
6
|
-
@parser = ShopParser.new(nil)
|
7
|
-
@lines = %|[wadedemt.myshopify.com] Processing ShopController#products (for 192.168.1.230 at 2009-07-24 14:58:21) [GET]
|
8
|
-
[wadedemt.myshopify.com] Processing ShopController#products (for 192.168.1.230 at 2009-07-24 14:58:21) [GET]
|
9
|
-
[test.myshopify.com] Processing ShopController#products (for 192.168.1.230 at 2009-07-24 14:58:21) [GET]
|
10
|
-
[my-shop.myshopify.com] Processing some other line of text
|
11
|
-
Jul 7 20:12:11 staging rails.shopify[27975]: [jessetesting.staging.shopify.com] Processing Admin::ProductsController#index (for 67.70.29.242 at 2009-07-07 20:12:11) [GET]
|
12
|
-
|.split("\n")
|
13
|
-
end
|
14
|
-
|
15
|
-
def test_parse_shop_name
|
16
|
-
line = @lines.first
|
17
|
-
out = @parser.parse(line)
|
18
|
-
|
19
|
-
assert out.has_key?(:shop)
|
20
|
-
assert out.has_key?(:line)
|
21
|
-
assert_equal "wadedemt.myshopify.com", out[:shop]
|
22
|
-
assert_equal "Processing ShopController#products (for 192.168.1.230 at 2009-07-24 14:58:21) [GET]", out[:line]
|
23
|
-
end
|
24
|
-
|
25
|
-
def test_parse_shop_name_with_extra_space
|
26
|
-
line = @lines[1]
|
27
|
-
out = @parser.parse(line)
|
28
|
-
|
29
|
-
assert out.has_key?(:shop)
|
30
|
-
assert out.has_key?(:line)
|
31
|
-
assert_equal "wadedemt.myshopify.com", out[:shop]
|
32
|
-
assert_equal "Processing ShopController#products (for 192.168.1.230 at 2009-07-24 14:58:21) [GET]", out[:line]
|
33
|
-
end
|
34
|
-
|
35
|
-
def test_parse_shop_name_with_dashes
|
36
|
-
line = @lines[3]
|
37
|
-
out = @parser.parse(line)
|
38
|
-
|
39
|
-
assert out.has_key?(:shop)
|
40
|
-
assert out.has_key?(:line)
|
41
|
-
assert_equal "my-shop.myshopify.com", out[:shop]
|
42
|
-
assert_equal "Processing some other line of text", out[:line]
|
43
|
-
end
|
44
|
-
|
45
|
-
def test_parse_with_no_shop_returns_line
|
46
|
-
line = @lines[4]
|
47
|
-
out = @parser.parse(line)
|
48
|
-
assert !out.has_key?(:shop)
|
49
|
-
assert_equal line, out[:line]
|
50
|
-
end
|
51
|
-
|
52
|
-
end
|
53
|
-
|
@@ -1,83 +0,0 @@
|
|
1
|
-
require 'test_helper'
|
2
|
-
|
3
|
-
class TimeParserTest < Test::Unit::TestCase
|
4
|
-
|
5
|
-
def setup
|
6
|
-
@params = { "sh" => "12", "sm" => "00", "ss" => "10", "eh" => "12", "em" => "00", "es" => "59" }
|
7
|
-
@lines = %|Jul 24 14:58:21 app3 rails.shopify[9855]: [wadedemt.myshopify.com] Processing ShopController#products (for 192.168.1.230 at 2009-07-24 14:58:21) [GET]
|
8
|
-
Jul 24 12:00:21 192.168.5.1 rails.shopify[9855]: [wadedemt.myshopify.com] Processing ShopController#products (for 192.168.1.230 at 2009-07-24 14:58:21) [GET]
|
9
|
-
Jul 24 12:00:31 192.168.5.1 rails.shopify[9855]: [test.myshopify.com] Processing ShopController#products (for 192.168.1.230 at 2009-07-24 14:58:21) [GET]
|
10
|
-
Jul 24 12:00:41 192.168.5.1 rails.shopify[9855]: [test2.myshopify.com] Processing some other line of text
|
11
|
-
|.split("\n")
|
12
|
-
end
|
13
|
-
|
14
|
-
def test_parse_timestamp
|
15
|
-
@parser = TimeParser.new(nil, {})
|
16
|
-
line = @lines.first
|
17
|
-
elements = @parser.parse(line)
|
18
|
-
|
19
|
-
assert elements.has_key?(:timestamp)
|
20
|
-
assert_equal "Jul 24 14:58:21", elements[:timestamp]
|
21
|
-
assert_equal "app3 rails.shopify[9855]: [wadedemt.myshopify.com] Processing ShopController#products (for 192.168.1.230 at 2009-07-24 14:58:21) [GET]", elements[:line]
|
22
|
-
end
|
23
|
-
|
24
|
-
def test_parse_with_start_time_and_early_timestamp
|
25
|
-
@parser = TimeParser.new(nil, {"sh" => "15", "sm" => "00", "ss" => "10"})
|
26
|
-
line = @lines.first
|
27
|
-
elements = @parser.parse(line)
|
28
|
-
|
29
|
-
# does not match - reject line all together
|
30
|
-
assert elements.empty?
|
31
|
-
end
|
32
|
-
|
33
|
-
def test_parse_with_start_time_and_later_timestamp
|
34
|
-
@parser = TimeParser.new(nil, {"sh" => "12", "sm" => "00", "ss" => "10"})
|
35
|
-
line = @lines[1]
|
36
|
-
elements = @parser.parse(line)
|
37
|
-
|
38
|
-
assert elements.has_key?(:timestamp)
|
39
|
-
assert elements.has_key?(:line)
|
40
|
-
end
|
41
|
-
|
42
|
-
def test_parse_with_end_time_and_early_timestamp
|
43
|
-
@parser = TimeParser.new(nil, {"eh" => "12", "em" => "00", "es" => "00"})
|
44
|
-
line = @lines.first
|
45
|
-
elements = @parser.parse(line)
|
46
|
-
|
47
|
-
assert elements.empty?
|
48
|
-
end
|
49
|
-
|
50
|
-
def test_parse_with_end_time_and_later_timestamp
|
51
|
-
@parser = TimeParser.new(nil, {"eh" => "13", "em" => "00", "es" => "00"})
|
52
|
-
line = @lines[1]
|
53
|
-
elements = @parser.parse(line)
|
54
|
-
|
55
|
-
assert elements.has_key?(:timestamp)
|
56
|
-
assert elements.has_key?(:line)
|
57
|
-
end
|
58
|
-
|
59
|
-
def test_parse_with_entry_between_start_and_end
|
60
|
-
@parser = TimeParser.new(nil, {"sh" => "14", "sm" => "00", "ss" => "00", "eh" => "15", "em" => "00", "es" => "00"})
|
61
|
-
line = @lines.first
|
62
|
-
elements = @parser.parse(line)
|
63
|
-
|
64
|
-
assert elements.has_key?(:timestamp)
|
65
|
-
assert elements.has_key?(:line)
|
66
|
-
end
|
67
|
-
|
68
|
-
def test_parse_with_entry_outside_start_and_end
|
69
|
-
@parser = TimeParser.new(nil, {"sh" => "14", "sm" => "00", "ss" => "00", "eh" => "15", "em" => "00", "es" => "00"})
|
70
|
-
line = @lines[1]
|
71
|
-
elements = @parser.parse(line)
|
72
|
-
|
73
|
-
assert elements.empty?
|
74
|
-
end
|
75
|
-
|
76
|
-
def test_parse_returns_entry_if_doesnt_match_parser
|
77
|
-
line = "July 24, 1999 12:00:21 192.168.5.1 rails.shopify[9855]: [wadedemt.myshopify.com] Processing ShopController#products (for 192.168.1.230 at 2009-07-24 14:58:21) [GET] "
|
78
|
-
@parser = TimeParser.new(nil)
|
79
|
-
elements = @parser.parse(line)
|
80
|
-
assert_equal line, elements[:line]
|
81
|
-
end
|
82
|
-
|
83
|
-
end
|