logster 2.1.0 → 2.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +19 -19
- data/.rubocop.yml +1 -1
- data/.travis.yml +16 -16
- data/CHANGELOG.md +169 -166
- data/Gemfile +4 -4
- data/Guardfile +8 -8
- data/LICENSE.txt +22 -22
- data/README.md +99 -99
- data/Rakefile +21 -21
- data/assets/fonts/FontAwesome.otf +0 -0
- data/assets/fonts/fontawesome-webfont.eot +0 -0
- data/assets/fonts/fontawesome-webfont.svg +639 -639
- data/assets/fonts/fontawesome-webfont.ttf +0 -0
- data/assets/fonts/fontawesome-webfont.woff +0 -0
- data/assets/fonts/fontawesome-webfont.woff2 +0 -0
- data/assets/images/Icon-144_rounded.png +0 -0
- data/assets/images/Icon-144_square.png +0 -0
- data/assets/images/icon_144x144.png +0 -0
- data/assets/images/icon_64x64.png +0 -0
- data/assets/javascript/client-app.js +100 -100
- data/assets/stylesheets/client-app.css +0 -0
- data/build_client_app.sh +0 -0
- data/client-app/.editorconfig +20 -20
- data/client-app/.ember-cli +9 -9
- data/client-app/.eslintignore +19 -19
- data/client-app/.eslintrc.js +46 -46
- data/client-app/.gitignore +23 -23
- data/client-app/.travis.yml +27 -27
- data/client-app/.watchmanconfig +3 -3
- data/client-app/README.md +57 -57
- data/client-app/app/app.js +14 -14
- data/client-app/app/components/actions-menu.js +37 -37
- data/client-app/app/components/env-tab.js +44 -44
- data/client-app/app/components/message-info.js +65 -65
- data/client-app/app/components/message-row.js +45 -45
- data/client-app/app/components/panel-resizer.js +74 -74
- data/client-app/app/components/tab-contents.js +27 -27
- data/client-app/app/components/tab-link.js +5 -5
- data/client-app/app/components/tabbed-section.js +32 -32
- data/client-app/app/components/time-formatter.js +25 -25
- data/client-app/app/components/update-time.js +21 -21
- data/client-app/app/controllers/index.js +105 -105
- data/client-app/app/controllers/show.js +13 -13
- data/client-app/app/index.html +29 -29
- data/client-app/app/initializers/app-init.js +72 -72
- data/client-app/app/lib/preload.js +14 -14
- data/client-app/app/lib/utilities.js +140 -140
- data/client-app/app/models/message-collection.js +178 -178
- data/client-app/app/models/message.js +100 -100
- data/client-app/app/resolver.js +3 -3
- data/client-app/app/router.js +14 -14
- data/client-app/app/routes/index.js +57 -57
- data/client-app/app/routes/show.js +14 -14
- data/client-app/app/styles/app.css +521 -521
- data/client-app/app/templates/application.hbs +2 -2
- data/client-app/app/templates/components/actions-menu.hbs +12 -12
- data/client-app/app/templates/components/env-tab.hbs +10 -10
- data/client-app/app/templates/components/message-info.hbs +41 -41
- data/client-app/app/templates/components/message-row.hbs +15 -15
- data/client-app/app/templates/components/panel-resizer.hbs +3 -3
- data/client-app/app/templates/components/tabbed-section.hbs +10 -10
- data/client-app/app/templates/components/time-formatter.hbs +1 -1
- data/client-app/app/templates/index.hbs +58 -58
- data/client-app/app/templates/show.hbs +7 -7
- data/client-app/config/environment.js +51 -51
- data/client-app/config/optional-features.json +3 -3
- data/client-app/config/targets.js +18 -18
- data/client-app/ember-cli-build.js +29 -29
- data/client-app/package-lock.json +11365 -11365
- data/client-app/package.json +56 -56
- data/client-app/testem.js +25 -25
- data/client-app/tests/index.html +34 -34
- data/client-app/tests/integration/components/actions-menu-test.js +26 -26
- data/client-app/tests/integration/components/env-tab-test.js +73 -73
- data/client-app/tests/integration/components/message-info-test.js +26 -26
- data/client-app/tests/integration/components/message-row-test.js +26 -26
- data/client-app/tests/integration/components/panel-resizer-test.js +26 -26
- data/client-app/tests/integration/components/tab-contents-test.js +26 -26
- data/client-app/tests/integration/components/tab-link-test.js +26 -26
- data/client-app/tests/integration/components/tabbed-section-test.js +26 -26
- data/client-app/tests/integration/components/time-formatter-test.js +26 -26
- data/client-app/tests/integration/components/update-time-test.js +26 -26
- data/client-app/tests/test-helper.js +8 -8
- data/client-app/tests/unit/controllers/index-test.js +12 -12
- data/client-app/tests/unit/controllers/show-test.js +12 -12
- data/client-app/tests/unit/initializers/app-init-test.js +31 -31
- data/client-app/tests/unit/routes/index-test.js +11 -11
- data/client-app/tests/unit/routes/show-test.js +11 -11
- data/lib/examples/sidekiq_logster_reporter.rb +21 -21
- data/lib/logster.rb +54 -54
- data/lib/logster/base_store.rb +141 -141
- data/lib/logster/configuration.rb +25 -25
- data/lib/logster/defer_logger.rb +14 -14
- data/lib/logster/ignore_pattern.rb +65 -65
- data/lib/logster/logger.rb +113 -113
- data/lib/logster/message.rb +212 -212
- data/lib/logster/middleware/debug_exceptions.rb +26 -26
- data/lib/logster/middleware/reporter.rb +55 -55
- data/lib/logster/middleware/viewer.rb +221 -221
- data/lib/logster/rails/railtie.rb +63 -63
- data/lib/logster/redis_store.rb +566 -566
- data/lib/logster/scheduler.rb +54 -40
- data/lib/logster/version.rb +3 -3
- data/lib/logster/web.rb +14 -14
- data/logster.gemspec +35 -35
- data/test/examples/test_sidekiq_reporter_example.rb +46 -46
- data/test/fake_data/Gemfile +4 -4
- data/test/fake_data/generate.rb +10 -10
- data/test/logster/middleware/test_reporter.rb +19 -19
- data/test/logster/middleware/test_viewer.rb +96 -96
- data/test/logster/test_base_store.rb +147 -147
- data/test/logster/test_defer_logger.rb +34 -34
- data/test/logster/test_ignore_pattern.rb +41 -41
- data/test/logster/test_logger.rb +86 -86
- data/test/logster/test_message.rb +119 -119
- data/test/logster/test_redis_rate_limiter.rb +230 -230
- data/test/logster/test_redis_store.rb +720 -720
- data/test/test_helper.rb +38 -38
- data/vendor/assets/javascripts/logster.js.erb +39 -39
- metadata +2 -2
data/lib/logster/scheduler.rb
CHANGED
@@ -1,40 +1,54 @@
|
|
1
|
-
module Logster
|
2
|
-
module Deferer
|
3
|
-
attr_reader :queue, :thread
|
4
|
-
def initialize
|
5
|
-
@queue = Queue.new
|
6
|
-
@mutex = Mutex.new
|
7
|
-
@thread = nil
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
@
|
13
|
-
end
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
1
|
+
module Logster
|
2
|
+
module Deferer
|
3
|
+
attr_reader :queue, :thread
|
4
|
+
def initialize
|
5
|
+
@queue = Queue.new
|
6
|
+
@mutex = Mutex.new
|
7
|
+
@thread = nil
|
8
|
+
@enabled = true
|
9
|
+
end
|
10
|
+
|
11
|
+
def disable
|
12
|
+
@enabled = false
|
13
|
+
end
|
14
|
+
|
15
|
+
def enable
|
16
|
+
@enabled = true
|
17
|
+
end
|
18
|
+
|
19
|
+
def schedule(&blk)
|
20
|
+
if @enabled
|
21
|
+
start_thread if !@thread&.alive?
|
22
|
+
@queue << blk
|
23
|
+
else
|
24
|
+
return if blk == :terminate
|
25
|
+
blk.call
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
private
|
30
|
+
|
31
|
+
def start_thread
|
32
|
+
@mutex.synchronize do
|
33
|
+
if !@thread&.alive?
|
34
|
+
@thread = Thread.new { do_work }
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
def do_work
|
40
|
+
while true
|
41
|
+
blk = @queue.pop
|
42
|
+
# we need to be able to break the loop so that the new
|
43
|
+
# thread "finishes" and let us test this code.
|
44
|
+
break if blk == :terminate
|
45
|
+
blk.call
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
class Scheduler
|
51
|
+
extend Deferer
|
52
|
+
initialize
|
53
|
+
end
|
54
|
+
end
|
data/lib/logster/version.rb
CHANGED
@@ -1,3 +1,3 @@
|
|
1
|
-
module Logster
|
2
|
-
VERSION = "2.1.
|
3
|
-
end
|
1
|
+
module Logster
|
2
|
+
VERSION = "2.1.1"
|
3
|
+
end
|
data/lib/logster/web.rb
CHANGED
@@ -1,14 +1,14 @@
|
|
1
|
-
require 'logster/middleware/viewer'
|
2
|
-
|
3
|
-
class Logster::Web
|
4
|
-
class FourOhFour
|
5
|
-
def call(env)
|
6
|
-
[404, {}, ["not found"]]
|
7
|
-
end
|
8
|
-
end
|
9
|
-
|
10
|
-
def self.call(env)
|
11
|
-
@middleware ||= Logster::Middleware::Viewer.new(FourOhFour.new)
|
12
|
-
@middleware.call(env)
|
13
|
-
end
|
14
|
-
end
|
1
|
+
require 'logster/middleware/viewer'
|
2
|
+
|
3
|
+
class Logster::Web
|
4
|
+
class FourOhFour
|
5
|
+
def call(env)
|
6
|
+
[404, {}, ["not found"]]
|
7
|
+
end
|
8
|
+
end
|
9
|
+
|
10
|
+
def self.call(env)
|
11
|
+
@middleware ||= Logster::Middleware::Viewer.new(FourOhFour.new)
|
12
|
+
@middleware.call(env)
|
13
|
+
end
|
14
|
+
end
|
data/logster.gemspec
CHANGED
@@ -1,35 +1,35 @@
|
|
1
|
-
# coding: utf-8
|
2
|
-
lib = File.expand_path('../lib', __FILE__)
|
3
|
-
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
-
require 'logster/version'
|
5
|
-
|
6
|
-
Gem::Specification.new do |spec|
|
7
|
-
spec.name = "logster"
|
8
|
-
spec.version = Logster::VERSION
|
9
|
-
spec.authors = ["UI for viewing logs in Rack"]
|
10
|
-
spec.email = ["sam.saffron@gmail.com"]
|
11
|
-
spec.summary = %q{UI for viewing logs in Rack}
|
12
|
-
spec.description = %q{UI for viewing logs in Rack}
|
13
|
-
spec.homepage = "https://github.com/discourse/logster"
|
14
|
-
spec.license = "MIT"
|
15
|
-
|
16
|
-
spec.files = `git ls-files -z`.split("\x0").reject do |f|
|
17
|
-
f.start_with?("bower_components") || f.start_with?("website") || f.start_with?("bin")
|
18
|
-
end
|
19
|
-
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
20
|
-
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
21
|
-
spec.require_paths = ["lib"]
|
22
|
-
|
23
|
-
# NOTE dependency on rack is not explicit, this enables us to use
|
24
|
-
# logster outside of rack (for reporting)
|
25
|
-
|
26
|
-
spec.add_development_dependency "bundler", "~> 1.6"
|
27
|
-
spec.add_development_dependency "rake"
|
28
|
-
spec.add_development_dependency "rack"
|
29
|
-
spec.add_development_dependency "redis"
|
30
|
-
spec.add_development_dependency "guard"
|
31
|
-
spec.add_development_dependency "guard-minitest"
|
32
|
-
spec.add_development_dependency "timecop"
|
33
|
-
spec.add_development_dependency "byebug"
|
34
|
-
spec.add_development_dependency "rubocop", "~> 0.61.1"
|
35
|
-
end
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'logster/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "logster"
|
8
|
+
spec.version = Logster::VERSION
|
9
|
+
spec.authors = ["UI for viewing logs in Rack"]
|
10
|
+
spec.email = ["sam.saffron@gmail.com"]
|
11
|
+
spec.summary = %q{UI for viewing logs in Rack}
|
12
|
+
spec.description = %q{UI for viewing logs in Rack}
|
13
|
+
spec.homepage = "https://github.com/discourse/logster"
|
14
|
+
spec.license = "MIT"
|
15
|
+
|
16
|
+
spec.files = `git ls-files -z`.split("\x0").reject do |f|
|
17
|
+
f.start_with?("bower_components") || f.start_with?("website") || f.start_with?("bin")
|
18
|
+
end
|
19
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
20
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
21
|
+
spec.require_paths = ["lib"]
|
22
|
+
|
23
|
+
# NOTE dependency on rack is not explicit, this enables us to use
|
24
|
+
# logster outside of rack (for reporting)
|
25
|
+
|
26
|
+
spec.add_development_dependency "bundler", "~> 1.6"
|
27
|
+
spec.add_development_dependency "rake"
|
28
|
+
spec.add_development_dependency "rack"
|
29
|
+
spec.add_development_dependency "redis"
|
30
|
+
spec.add_development_dependency "guard"
|
31
|
+
spec.add_development_dependency "guard-minitest"
|
32
|
+
spec.add_development_dependency "timecop"
|
33
|
+
spec.add_development_dependency "byebug"
|
34
|
+
spec.add_development_dependency "rubocop", "~> 0.61.1"
|
35
|
+
end
|
@@ -1,46 +1,46 @@
|
|
1
|
-
require_relative '../test_helper'
|
2
|
-
require 'logster/logger'
|
3
|
-
require 'logster/redis_store'
|
4
|
-
require 'logger'
|
5
|
-
require 'examples/sidekiq_logster_reporter'
|
6
|
-
|
7
|
-
class TestSidekiqReporter < MiniTest::Test
|
8
|
-
|
9
|
-
def setup
|
10
|
-
Logster.store = @store = Logster::RedisStore.new(Redis.new)
|
11
|
-
Logster.logger = @logger = Logster::Logger.new(Logster.store)
|
12
|
-
@store.clear_all
|
13
|
-
end
|
14
|
-
|
15
|
-
def teardown
|
16
|
-
@store.clear_all
|
17
|
-
end
|
18
|
-
|
19
|
-
def test_sidekiq_handler_example
|
20
|
-
handler = SidekiqLogsterReporter.new
|
21
|
-
error = nil
|
22
|
-
begin
|
23
|
-
raise TypeError.new
|
24
|
-
rescue => e
|
25
|
-
error = e
|
26
|
-
end
|
27
|
-
trace = error.backtrace
|
28
|
-
|
29
|
-
handler.call(error, code: "Test", something_important: "Foo", params: { article_id: 20 })
|
30
|
-
|
31
|
-
report = @store.latest[0]
|
32
|
-
|
33
|
-
# Message is right format
|
34
|
-
assert_equal("Job exception: TypeError\n", report.message)
|
35
|
-
|
36
|
-
# A backtrace is joined()
|
37
|
-
assert_equal(trace.join("\n"), report.backtrace)
|
38
|
-
# The backtrace is deleted from the env
|
39
|
-
assert_nil(report.env['backtrace'])
|
40
|
-
assert_nil(report.env[:backtrace])
|
41
|
-
|
42
|
-
# The env is in the report
|
43
|
-
assert_equal("Test", report.env['code'])
|
44
|
-
assert_equal(20, report.env['params']['article_id'])
|
45
|
-
end
|
46
|
-
end
|
1
|
+
require_relative '../test_helper'
|
2
|
+
require 'logster/logger'
|
3
|
+
require 'logster/redis_store'
|
4
|
+
require 'logger'
|
5
|
+
require 'examples/sidekiq_logster_reporter'
|
6
|
+
|
7
|
+
class TestSidekiqReporter < MiniTest::Test
|
8
|
+
|
9
|
+
def setup
|
10
|
+
Logster.store = @store = Logster::RedisStore.new(Redis.new)
|
11
|
+
Logster.logger = @logger = Logster::Logger.new(Logster.store)
|
12
|
+
@store.clear_all
|
13
|
+
end
|
14
|
+
|
15
|
+
def teardown
|
16
|
+
@store.clear_all
|
17
|
+
end
|
18
|
+
|
19
|
+
def test_sidekiq_handler_example
|
20
|
+
handler = SidekiqLogsterReporter.new
|
21
|
+
error = nil
|
22
|
+
begin
|
23
|
+
raise TypeError.new
|
24
|
+
rescue => e
|
25
|
+
error = e
|
26
|
+
end
|
27
|
+
trace = error.backtrace
|
28
|
+
|
29
|
+
handler.call(error, code: "Test", something_important: "Foo", params: { article_id: 20 })
|
30
|
+
|
31
|
+
report = @store.latest[0]
|
32
|
+
|
33
|
+
# Message is right format
|
34
|
+
assert_equal("Job exception: TypeError\n", report.message)
|
35
|
+
|
36
|
+
# A backtrace is joined()
|
37
|
+
assert_equal(trace.join("\n"), report.backtrace)
|
38
|
+
# The backtrace is deleted from the env
|
39
|
+
assert_nil(report.env['backtrace'])
|
40
|
+
assert_nil(report.env[:backtrace])
|
41
|
+
|
42
|
+
# The env is in the report
|
43
|
+
assert_equal("Test", report.env['code'])
|
44
|
+
assert_equal(20, report.env['params']['article_id'])
|
45
|
+
end
|
46
|
+
end
|
data/test/fake_data/Gemfile
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
source 'https://rubygems.org'
|
2
|
-
|
3
|
-
gem 'redis'
|
4
|
-
gem 'logster', path: '../../'
|
1
|
+
source 'https://rubygems.org'
|
2
|
+
|
3
|
+
gem 'redis'
|
4
|
+
gem 'logster', path: '../../'
|
data/test/fake_data/generate.rb
CHANGED
@@ -1,10 +1,10 @@
|
|
1
|
-
require 'redis'
|
2
|
-
require 'logster'
|
3
|
-
|
4
|
-
Logster.config.allow_grouping = true
|
5
|
-
Logster.config.application_version = "ABC123"
|
6
|
-
Logster.store = Logster::RedisStore.new
|
7
|
-
|
8
|
-
10.times do
|
9
|
-
Logster.store.report(Logger::WARN, "application", "test warning", backtrace: "method1\nmethod2", env: { something: ["hello world", "hello places"], another: { thing: "something else" } })
|
10
|
-
end
|
1
|
+
require 'redis'
|
2
|
+
require 'logster'
|
3
|
+
|
4
|
+
Logster.config.allow_grouping = true
|
5
|
+
Logster.config.application_version = "ABC123"
|
6
|
+
Logster.store = Logster::RedisStore.new
|
7
|
+
|
8
|
+
10.times do
|
9
|
+
Logster.store.report(Logger::WARN, "application", "test warning", backtrace: "method1\nmethod2", env: { something: ["hello world", "hello places"], another: { thing: "something else" } })
|
10
|
+
end
|
@@ -1,19 +1,19 @@
|
|
1
|
-
require_relative '../../test_helper'
|
2
|
-
require 'rack'
|
3
|
-
require 'logster/redis_store'
|
4
|
-
require 'logster/middleware/reporter'
|
5
|
-
|
6
|
-
class TestReporter < Minitest::Test
|
7
|
-
|
8
|
-
def test_logs_errors
|
9
|
-
Logster.store = Logster::TestStore.new
|
10
|
-
|
11
|
-
reporter = Logster::Middleware::Reporter.new(nil)
|
12
|
-
env = Rack::MockRequest.env_for("/logs/report_js_error?message=hello")
|
13
|
-
status, = reporter.call(env)
|
14
|
-
|
15
|
-
assert_equal(200, status)
|
16
|
-
assert_equal(1, Logster.store.count)
|
17
|
-
end
|
18
|
-
|
19
|
-
end
|
1
|
+
require_relative '../../test_helper'
|
2
|
+
require 'rack'
|
3
|
+
require 'logster/redis_store'
|
4
|
+
require 'logster/middleware/reporter'
|
5
|
+
|
6
|
+
class TestReporter < Minitest::Test
|
7
|
+
|
8
|
+
def test_logs_errors
|
9
|
+
Logster.store = Logster::TestStore.new
|
10
|
+
|
11
|
+
reporter = Logster::Middleware::Reporter.new(nil)
|
12
|
+
env = Rack::MockRequest.env_for("/logs/report_js_error?message=hello")
|
13
|
+
status, = reporter.call(env)
|
14
|
+
|
15
|
+
assert_equal(200, status)
|
16
|
+
assert_equal(1, Logster.store.count)
|
17
|
+
end
|
18
|
+
|
19
|
+
end
|
@@ -1,96 +1,96 @@
|
|
1
|
-
require_relative '../../test_helper'
|
2
|
-
require 'rack'
|
3
|
-
require 'logster/redis_store'
|
4
|
-
require 'logster/middleware/viewer'
|
5
|
-
|
6
|
-
class TestViewer < Minitest::Test
|
7
|
-
|
8
|
-
class BrokenApp
|
9
|
-
def call(env)
|
10
|
-
[500, {}, ["broken"]]
|
11
|
-
end
|
12
|
-
end
|
13
|
-
|
14
|
-
def setup
|
15
|
-
Logster.config.subdirectory = "/logsie"
|
16
|
-
Logster.store = Logster::RedisStore.new
|
17
|
-
end
|
18
|
-
|
19
|
-
def teardown
|
20
|
-
Logster.config.subdirectory = nil
|
21
|
-
Logster.store = nil
|
22
|
-
end
|
23
|
-
|
24
|
-
def viewer
|
25
|
-
@viewer ||= Logster::Middleware::Viewer.new(nil)
|
26
|
-
end
|
27
|
-
|
28
|
-
def request
|
29
|
-
@request ||= Rack::MockRequest.new(Rack::Lint.new(viewer))
|
30
|
-
end
|
31
|
-
|
32
|
-
def test_path_resolution
|
33
|
-
assert_nil(viewer.send(:resolve_path, "/logs"))
|
34
|
-
assert_nil(viewer.send(:resolve_path, "/admin/logsie"))
|
35
|
-
assert_nil(viewer.send(:resolve_path, "/admin/logsie/bla"))
|
36
|
-
assert_equal("/", viewer.send(:resolve_path, "/logsie"))
|
37
|
-
assert_equal("/", viewer.send(:resolve_path, "/logsie/"))
|
38
|
-
assert_equal("/hello/world", viewer.send(:resolve_path, "/logsie/hello/world"))
|
39
|
-
end
|
40
|
-
|
41
|
-
def test_search_raceguard_s
|
42
|
-
response = request.get('/logsie/messages.json?search=searchkey')
|
43
|
-
result = JSON.parse(response.body)
|
44
|
-
assert_equal('searchkey', result['search'])
|
45
|
-
end
|
46
|
-
|
47
|
-
def test_search_raceguard_sr
|
48
|
-
response = request.get('/logsie/messages.json?search=/regex/®ex_search=true')
|
49
|
-
result = JSON.parse(response.body)
|
50
|
-
assert_equal('/regex/', result['search'])
|
51
|
-
end
|
52
|
-
|
53
|
-
def test_search_raceguard_f
|
54
|
-
response = request.get("/logsie/messages.json?filter=0_1_2_3_4")
|
55
|
-
result = JSON.parse(response.body)
|
56
|
-
assert_equal([0, 1, 2, 3, 4], result['filter'])
|
57
|
-
end
|
58
|
-
|
59
|
-
def test_regex_parse
|
60
|
-
assert_equal(/hello/i, viewer.send(:parse_regex, '/hello/i'))
|
61
|
-
end
|
62
|
-
|
63
|
-
def test_linking_to_a_valid_js_files
|
64
|
-
%w(
|
65
|
-
/logsie/javascript/client-app.js
|
66
|
-
/logsie/javascript/vendor.js
|
67
|
-
).each do |path|
|
68
|
-
response = request.get(path)
|
69
|
-
assert_equal(200, response.status)
|
70
|
-
assert_equal('application/javascript', response.headers['Content-Type'])
|
71
|
-
end
|
72
|
-
end
|
73
|
-
|
74
|
-
def test_linking_to_a_valid_css_files
|
75
|
-
%w(
|
76
|
-
/logsie/stylesheets/client-app.css
|
77
|
-
/logsie/stylesheets/vendor.css
|
78
|
-
).each do |path|
|
79
|
-
response = request.get(path)
|
80
|
-
assert_equal(200, response.status)
|
81
|
-
assert_equal('text/css', response.headers['Content-Type'])
|
82
|
-
end
|
83
|
-
end
|
84
|
-
|
85
|
-
def test_linking_to_an_invalid_ember_component_or_template
|
86
|
-
%w(
|
87
|
-
/logsie/javascript/templates/application.hbs
|
88
|
-
/logsie/javascript/templates/does_not_exist.js
|
89
|
-
/logsie/javascript/components/does_not_exist.js
|
90
|
-
/logsie/javascript/templates/../../app.js
|
91
|
-
).each do |path|
|
92
|
-
response = request.get(path)
|
93
|
-
assert_equal(404, response.status, "#{path} should have 404'ed")
|
94
|
-
end
|
95
|
-
end
|
96
|
-
end
|
1
|
+
require_relative '../../test_helper'
|
2
|
+
require 'rack'
|
3
|
+
require 'logster/redis_store'
|
4
|
+
require 'logster/middleware/viewer'
|
5
|
+
|
6
|
+
class TestViewer < Minitest::Test
|
7
|
+
|
8
|
+
class BrokenApp
|
9
|
+
def call(env)
|
10
|
+
[500, {}, ["broken"]]
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
def setup
|
15
|
+
Logster.config.subdirectory = "/logsie"
|
16
|
+
Logster.store = Logster::RedisStore.new
|
17
|
+
end
|
18
|
+
|
19
|
+
def teardown
|
20
|
+
Logster.config.subdirectory = nil
|
21
|
+
Logster.store = nil
|
22
|
+
end
|
23
|
+
|
24
|
+
def viewer
|
25
|
+
@viewer ||= Logster::Middleware::Viewer.new(nil)
|
26
|
+
end
|
27
|
+
|
28
|
+
def request
|
29
|
+
@request ||= Rack::MockRequest.new(Rack::Lint.new(viewer))
|
30
|
+
end
|
31
|
+
|
32
|
+
def test_path_resolution
|
33
|
+
assert_nil(viewer.send(:resolve_path, "/logs"))
|
34
|
+
assert_nil(viewer.send(:resolve_path, "/admin/logsie"))
|
35
|
+
assert_nil(viewer.send(:resolve_path, "/admin/logsie/bla"))
|
36
|
+
assert_equal("/", viewer.send(:resolve_path, "/logsie"))
|
37
|
+
assert_equal("/", viewer.send(:resolve_path, "/logsie/"))
|
38
|
+
assert_equal("/hello/world", viewer.send(:resolve_path, "/logsie/hello/world"))
|
39
|
+
end
|
40
|
+
|
41
|
+
def test_search_raceguard_s
|
42
|
+
response = request.get('/logsie/messages.json?search=searchkey')
|
43
|
+
result = JSON.parse(response.body)
|
44
|
+
assert_equal('searchkey', result['search'])
|
45
|
+
end
|
46
|
+
|
47
|
+
def test_search_raceguard_sr
|
48
|
+
response = request.get('/logsie/messages.json?search=/regex/®ex_search=true')
|
49
|
+
result = JSON.parse(response.body)
|
50
|
+
assert_equal('/regex/', result['search'])
|
51
|
+
end
|
52
|
+
|
53
|
+
def test_search_raceguard_f
|
54
|
+
response = request.get("/logsie/messages.json?filter=0_1_2_3_4")
|
55
|
+
result = JSON.parse(response.body)
|
56
|
+
assert_equal([0, 1, 2, 3, 4], result['filter'])
|
57
|
+
end
|
58
|
+
|
59
|
+
def test_regex_parse
|
60
|
+
assert_equal(/hello/i, viewer.send(:parse_regex, '/hello/i'))
|
61
|
+
end
|
62
|
+
|
63
|
+
def test_linking_to_a_valid_js_files
|
64
|
+
%w(
|
65
|
+
/logsie/javascript/client-app.js
|
66
|
+
/logsie/javascript/vendor.js
|
67
|
+
).each do |path|
|
68
|
+
response = request.get(path)
|
69
|
+
assert_equal(200, response.status)
|
70
|
+
assert_equal('application/javascript', response.headers['Content-Type'])
|
71
|
+
end
|
72
|
+
end
|
73
|
+
|
74
|
+
def test_linking_to_a_valid_css_files
|
75
|
+
%w(
|
76
|
+
/logsie/stylesheets/client-app.css
|
77
|
+
/logsie/stylesheets/vendor.css
|
78
|
+
).each do |path|
|
79
|
+
response = request.get(path)
|
80
|
+
assert_equal(200, response.status)
|
81
|
+
assert_equal('text/css', response.headers['Content-Type'])
|
82
|
+
end
|
83
|
+
end
|
84
|
+
|
85
|
+
def test_linking_to_an_invalid_ember_component_or_template
|
86
|
+
%w(
|
87
|
+
/logsie/javascript/templates/application.hbs
|
88
|
+
/logsie/javascript/templates/does_not_exist.js
|
89
|
+
/logsie/javascript/components/does_not_exist.js
|
90
|
+
/logsie/javascript/templates/../../app.js
|
91
|
+
).each do |path|
|
92
|
+
response = request.get(path)
|
93
|
+
assert_equal(404, response.status, "#{path} should have 404'ed")
|
94
|
+
end
|
95
|
+
end
|
96
|
+
end
|