logster 0.1.1 → 0.1.2
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.
- checksums.yaml +4 -4
- data/README.md +6 -0
- data/assets/javascript/app.js +5 -3
- data/assets/javascript/templates/show.handlebars +1 -0
- data/lib/logster.rb +2 -2
- data/lib/logster/base_store.rb +5 -4
- data/lib/logster/ignore_pattern.rb +61 -0
- data/lib/logster/message.rb +15 -0
- data/lib/logster/version.rb +1 -1
- data/test/logster/test_base_store.rb +52 -0
- data/vendor/assets/javascripts/logster.js.erb +13 -4
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 27abd7df3fc47f5af41862411fc506de6a205a43
|
4
|
+
data.tar.gz: 1875f195f059603f9e14093ea9afd200b927a125
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ea1b1899505c10ad68907ead7fcada96fd9998528c8750ffb877616cb29ac9a7064d8167097d7b9691337d2393a7843be3caf836986f835f41d142f2418761a5
|
7
|
+
data.tar.gz: 641d21916328714c2290d8d42fb24698b5d3f67d5a895fe531de6fc1487d4097d9f352382335972e2e6ad511ddcdb1376d77ff02013fa15693cc284541d04216
|
data/README.md
CHANGED
@@ -74,3 +74,9 @@ Logster UI is built using [Ember.js](http://emberjs.com/)
|
|
74
74
|
- Feature: Able to share logs, at /logs/show/(hexdigits)
|
75
75
|
- Add protecting logs, so they aren't deleted when old (for use with sharing)
|
76
76
|
- Restructured Redis data model
|
77
|
+
- 2014-07-17: Version 0.1.1
|
78
|
+
- Refactored report method into base_store.rb - will be easier to make a new log store
|
79
|
+
- Add link in UI to clear all (non-protected) logs
|
80
|
+
- Add example of submitting logs from Sidekiq jobs
|
81
|
+
- Show Protect/Share links on all tabs
|
82
|
+
- Render hashes provided via Logster.add_to_env
|
data/assets/javascript/app.js
CHANGED
@@ -308,9 +308,11 @@ App.IndexController = Em.Controller.extend({
|
|
308
308
|
|
309
309
|
clear: function() {
|
310
310
|
var self = this;
|
311
|
-
|
312
|
-
|
313
|
-
|
311
|
+
if (confirm("Clear the logs?\n\nCancel = No, OK = Clear")) {
|
312
|
+
App.ajax("/clear", { type: "POST" }).success(function() {
|
313
|
+
self.get('model').reload();
|
314
|
+
});
|
315
|
+
}
|
314
316
|
},
|
315
317
|
|
316
318
|
protect: function(message) {
|
data/lib/logster.rb
CHANGED
@@ -34,8 +34,8 @@ module Logster
|
|
34
34
|
end
|
35
35
|
end
|
36
36
|
|
37
|
-
Logster.config.current_context = lambda{|env, &block| block.call}
|
38
|
-
Logster.config.authorize_callback = lambda{|env| true}
|
37
|
+
Logster.config.current_context = lambda{ |env, &block| block.call }
|
38
|
+
Logster.config.authorize_callback = lambda{ |env| true }
|
39
39
|
|
40
40
|
if defined?(::Rails) && ::Rails::VERSION::MAJOR.to_i >= 3
|
41
41
|
require 'logster/rails/railtie'
|
data/lib/logster/base_store.rb
CHANGED
@@ -38,12 +38,11 @@ module Logster
|
|
38
38
|
not_implemented
|
39
39
|
end
|
40
40
|
|
41
|
-
def report(severity, progname,
|
42
|
-
return if (!
|
41
|
+
def report(severity, progname, msg, opts = {})
|
42
|
+
return if (!msg || (String === msg && msg.empty?)) && skip_empty
|
43
43
|
return if level && severity < level
|
44
|
-
return if ignore && ignore.any? { |pattern| message =~ pattern}
|
45
44
|
|
46
|
-
message = Logster::Message.new(severity, progname,
|
45
|
+
message = Logster::Message.new(severity, progname, msg, opts[:timestamp])
|
47
46
|
|
48
47
|
env = opts[:env]
|
49
48
|
backtrace = opts[:backtrace]
|
@@ -66,6 +65,8 @@ module Logster
|
|
66
65
|
message.backtrace = caller.join("\n")
|
67
66
|
end
|
68
67
|
|
68
|
+
return if ignore && ignore.any? { |pattern| message =~ pattern}
|
69
|
+
|
69
70
|
save message
|
70
71
|
|
71
72
|
message
|
@@ -0,0 +1,61 @@
|
|
1
|
+
module Logster
|
2
|
+
class IgnorePattern
|
3
|
+
|
4
|
+
def initialize(message_pattern=nil, env_patterns=nil)
|
5
|
+
@msg_match = message_pattern
|
6
|
+
@env_match = env_patterns
|
7
|
+
end
|
8
|
+
|
9
|
+
def self.from_message_and_request_uri(msg, request)
|
10
|
+
IgnorePattern.new(msg, {REQUEST_URI: request})
|
11
|
+
end
|
12
|
+
|
13
|
+
def matches?(message)
|
14
|
+
if @msg_match
|
15
|
+
return false unless compare(message.message, @msg_match)
|
16
|
+
end
|
17
|
+
|
18
|
+
if @env_match
|
19
|
+
return false unless compare(message.env, @env_match)
|
20
|
+
end
|
21
|
+
|
22
|
+
true
|
23
|
+
end
|
24
|
+
|
25
|
+
def to_s
|
26
|
+
"<#Logster::IgnorePattern, msg_match: #{@msg_match.inspect}, env_match: #{@env_match.inspect}>"
|
27
|
+
end
|
28
|
+
|
29
|
+
private
|
30
|
+
|
31
|
+
def compare(message, pattern)
|
32
|
+
case pattern
|
33
|
+
when Regexp
|
34
|
+
message =~ pattern
|
35
|
+
when String
|
36
|
+
message.downcase =~ Regexp.new(pattern.downcase, Regexp::IGNORECASE)
|
37
|
+
when Hash
|
38
|
+
compare_hash(message, pattern)
|
39
|
+
when NilClass
|
40
|
+
true
|
41
|
+
else
|
42
|
+
true
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
def compare_hash(message_hash, pattern_hash)
|
47
|
+
return false unless message_hash
|
48
|
+
pattern_hash.each do |key, value|
|
49
|
+
return false unless compare(get_indifferent(message_hash, key), value)
|
50
|
+
end
|
51
|
+
true
|
52
|
+
end
|
53
|
+
|
54
|
+
def get_indifferent(hash, key)
|
55
|
+
return hash[key] if hash[key]
|
56
|
+
return hash[key.to_s] if hash[key.to_s]
|
57
|
+
return hash[key.to_sym] if hash[key.to_sym]
|
58
|
+
nil
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
data/lib/logster/message.rb
CHANGED
@@ -92,6 +92,21 @@ module Logster
|
|
92
92
|
self.key <=> other.key
|
93
93
|
end
|
94
94
|
|
95
|
+
def =~(pattern)
|
96
|
+
case pattern
|
97
|
+
when Hash
|
98
|
+
IgnorePattern.new(nil, pattern).matches? self
|
99
|
+
when String
|
100
|
+
IgnorePattern.new(pattern, nil).matches? self
|
101
|
+
when Regexp
|
102
|
+
IgnorePattern.new(pattern, nil).matches? self
|
103
|
+
when IgnorePattern
|
104
|
+
pattern.matches? self
|
105
|
+
else
|
106
|
+
nil
|
107
|
+
end
|
108
|
+
end
|
109
|
+
|
95
110
|
protected
|
96
111
|
|
97
112
|
def get_timestamp
|
data/lib/logster/version.rb
CHANGED
@@ -1,5 +1,6 @@
|
|
1
1
|
require_relative '../test_helper'
|
2
2
|
require 'logster/base_store'
|
3
|
+
require 'logster/ignore_pattern'
|
3
4
|
|
4
5
|
class TestBaseStore < Minitest::Test
|
5
6
|
|
@@ -50,6 +51,57 @@ class TestBaseStore < Minitest::Test
|
|
50
51
|
assert_equal(4, @store.count)
|
51
52
|
end
|
52
53
|
|
54
|
+
def test_ignore_pattern_basic
|
55
|
+
@store.ignore = [
|
56
|
+
Logster::IgnorePattern.new(nil, {username: 'CausingErrors'})
|
57
|
+
]
|
58
|
+
@store.report(Logger::WARN, "test", "Foobar") #
|
59
|
+
@store.report(Logger::WARN, "test", "Foobar", { env: { username: 'CausingErrors' }})
|
60
|
+
@store.report(Logger::WARN, "test", "Something Else", { env: { username: 'CausingErrors' }})
|
61
|
+
@store.report(Logger::WARN, "test", "Something Else", { env: { 'username' => 'CausingErrors' }})
|
62
|
+
@store.report(Logger::WARN, "test", "Something Else", { env: { username: 'GoodPerson' }}) #
|
63
|
+
@store.report(Logger::WARN, "test", "Can't verify CSRF token authenticity") #
|
64
|
+
|
65
|
+
assert_equal(3, @store.count)
|
66
|
+
end
|
67
|
+
|
68
|
+
def test_ignore_pattern_real
|
69
|
+
@store.ignore = [
|
70
|
+
/^ActionController::RoutingError \(No route matches/,
|
71
|
+
Logster::IgnorePattern.new("Can't verify CSRF token authenticity", { REQUEST_URI: /\/trackback\/$/ })
|
72
|
+
]
|
73
|
+
# blocked
|
74
|
+
@store.report(Logger::WARN, "whatever", "Can't verify CSRF token authenticity", {
|
75
|
+
env: {
|
76
|
+
HTTP_HOST: 'meta.discourse.org',
|
77
|
+
REQUEST_URI: '/t/use-more-standard-smiley-codes-instead-of-smile/1822/trackback/',
|
78
|
+
REQUEST_METHOD: 'POST',
|
79
|
+
HTTP_USER_AGENT: 'Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1)',
|
80
|
+
params: {
|
81
|
+
title: 'Something Spammy',
|
82
|
+
url: 'http://spam.example.net/whatever/spam.html',
|
83
|
+
excerpt: 'http://spam.example.com/pdf/blahblah.html free viagra',
|
84
|
+
blog_name: 'get free spam for cheap'
|
85
|
+
}
|
86
|
+
}
|
87
|
+
})
|
88
|
+
# logged
|
89
|
+
@store.report(Logger::WARN, "whatever", "Can't verify CSRF token authenticity", {
|
90
|
+
env: {
|
91
|
+
HTTP_HOST: 'meta.discourse.org',
|
92
|
+
REQUEST_URI: '/session',
|
93
|
+
REQUEST_METHOD: 'POST',
|
94
|
+
HTTP_USER_AGENT: 'Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/35.0.1916.153 Safari/537.36',
|
95
|
+
params: {
|
96
|
+
username: 'user',
|
97
|
+
password: 'password',
|
98
|
+
form_authenticity_token: 'incorrect'
|
99
|
+
}
|
100
|
+
}
|
101
|
+
})
|
102
|
+
assert_equal(1, @store.count)
|
103
|
+
end
|
104
|
+
|
53
105
|
def test_timestamp
|
54
106
|
time = Time.now - 24*60*60
|
55
107
|
message = @store.report(Logger::WARN, "test", "B", timestamp: time)
|
@@ -1,9 +1,18 @@
|
|
1
|
-
(function(){
|
1
|
+
(function() {
|
2
2
|
var lastReport = null;
|
3
3
|
|
4
|
+
if (!window.Logster) {
|
5
|
+
window.Logster = {
|
6
|
+
enabled: true
|
7
|
+
};
|
8
|
+
}
|
9
|
+
|
4
10
|
window.onerror = function(message, url, line, column, errorObj) {
|
5
11
|
// never bother reporting more than once a minute
|
6
|
-
if(lastReport && new Date() - lastReport < 1000 * 60) {
|
12
|
+
if (lastReport && new Date() - lastReport < 1000 * 60) {
|
13
|
+
return;
|
14
|
+
}
|
15
|
+
if (!Logster.enabled) {
|
7
16
|
return;
|
8
17
|
}
|
9
18
|
|
@@ -17,11 +26,11 @@
|
|
17
26
|
window_location: window.location && (window.location + "")
|
18
27
|
};
|
19
28
|
|
20
|
-
if(errorObj && errorObj.stack) {
|
29
|
+
if (errorObj && errorObj.stack) {
|
21
30
|
err.stacktrace = errorObj.stack;
|
22
31
|
}
|
23
32
|
|
24
|
-
$.ajax("<%= Logster.config.subdirectory || '/logs' %>" + "/report_js_error",{
|
33
|
+
$.ajax("<%= Logster.config.subdirectory || '/logs' %>" + "/report_js_error", {
|
25
34
|
data: err,
|
26
35
|
type: "POST",
|
27
36
|
cache: false
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: logster
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- UI for viewing logs in Rack
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-07-
|
11
|
+
date: 2014-07-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -128,6 +128,7 @@ files:
|
|
128
128
|
- lib/logster.rb
|
129
129
|
- lib/logster/base_store.rb
|
130
130
|
- lib/logster/configuration.rb
|
131
|
+
- lib/logster/ignore_pattern.rb
|
131
132
|
- lib/logster/logger.rb
|
132
133
|
- lib/logster/message.rb
|
133
134
|
- lib/logster/middleware/debug_exceptions.rb
|