logster 0.0.11 → 0.0.12

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: ffac6b3153b63a23916214aa819293b81483ce41
4
- data.tar.gz: 3750f61bc3cddfd46bf8069d6a35ac27349cd59c
3
+ metadata.gz: b21c5ac2f54261afd0a6b2b35bff091e19b8c585
4
+ data.tar.gz: 2f14a5000271e1017c380379cbcf377025747eda
5
5
  SHA512:
6
- metadata.gz: a5099353cb310d52c6095703370c29538c20fae71855b9d4c840cfb0f445c97a7d7805a730eb185b88f92b1374cb48995b05233cb291ba2b8800d7bda5c28d53
7
- data.tar.gz: 4b0f69413fa4fd45f1d328298aac52232d0578204332263c5b279d64c017c2d09bc9a1d6169095f1e69a5e6c311a0c41742a109e96766d9d44a4df05ee3c3a1e
6
+ metadata.gz: 423e3ed1d419725174e2593f237274821edcc0b904f7286d7e88f0afccc040a321de66a9d410b6e646b153060f0fd094a54fa46c6387e8f418b1c48a49c50994
7
+ data.tar.gz: 59143d70c2839be397e98025ae4d66fd4e987e3bc86d7d5c382f851cd4cafa19fc7fc79f7549a85096fa56b8a4ec08cec72221c2fb4857cd2aa5b2bd74eb4856
@@ -59,12 +59,12 @@ App.Message = Ember.Object.extend({
59
59
  },
60
60
 
61
61
  protect: function() {
62
- this.set('saved', true);
62
+ this.set('protected', true);
63
63
  return App.ajax("/protect/" + this.get('key'), { type: "PUT" });
64
64
  },
65
65
  unprotect: function() {
66
- this.set('saved', false);
67
- return App.ajax("/protect/" + this.get('key'), { type: "DELETE" });
66
+ this.set('protected', false);
67
+ return App.ajax("/unprotect/" + this.get('key'), { type: "DELETE" });
68
68
  },
69
69
 
70
70
  hasMore: function(){
@@ -78,6 +78,10 @@ App.Message = Ember.Object.extend({
78
78
  return Logger.rootPath + "/show/" + this.get('key');
79
79
  }.property("key"),
80
80
 
81
+ protectUrl: function() {
82
+ return Logger.rootPath + (this.get('protected') ? '/unprotect/' : '/protect/') + this.get('key');
83
+ }.property("key"),
84
+
81
85
  displayMessage: function(){
82
86
  var message = this.get("message");
83
87
  var expanded = this.get("expanded");
@@ -279,16 +283,6 @@ App.ShowRoute = Em.Route.extend({
279
283
  resolve(App.Message.create(json));
280
284
  }).error(reject);
281
285
  });
282
- },
283
-
284
- actions: {
285
- protect: function(message) {
286
- this.get('model').protect();
287
- },
288
-
289
- unprotect: function(message) {
290
- this.get('model').unprotect();
291
- }
292
286
  }
293
287
  });
294
288
 
@@ -370,6 +364,18 @@ App.IndexController = Em.Controller.extend({
370
364
  }
371
365
  });
372
366
 
367
+ App.ShowController = Em.Controller.extend({
368
+ actions: {
369
+ protect: function(message) {
370
+ this.get('model').protect();
371
+ },
372
+
373
+ unprotect: function(message) {
374
+ this.get('model').unprotect();
375
+ }
376
+ }
377
+ });
378
+
373
379
  App.IndexView = Em.View.extend({
374
380
  divideView: function(fromTop, win){
375
381
  var $win = win || $(window);
@@ -4,11 +4,13 @@
4
4
  <pre>{{currentMessage.message}}</pre>
5
5
  {{#if currentMessage}}
6
6
  <a {{bind-attr href=currentMessage.shareUrl}} class="share">Share</a>
7
- {{#if currentMessage.saved}}
8
- <a {{action unprotect currentMessage}} href class="save">Unprotect</a>
9
- {{else}}
10
- <a {{action protect currentMessage}} href class="save">Protect</a>
11
- {{/if}}
7
+ <a {{bind-attr href=currentMessage.protectUrl}} class="save">
8
+ {{#if currentMessage.protected}}
9
+ Unprotect
10
+ {{else}}
11
+ Protect
12
+ {{/if}}
13
+ </a>
12
14
  {{/if}}
13
15
  {{/tab-contents}}
14
16
  {{#tab-contents name="backtrace" hint="show backtrace"}}<pre>{{currentMessage.backtrace}}</pre>{{/tab-contents}}
@@ -1,5 +1,3 @@
1
- <div id='top-panel'></div>
2
- <div id="divider"></div>
3
- <div id="bottom-panel">
1
+ <div id="bottom-panel" class="full">
4
2
  {{message-info currentMessage=model}}
5
3
  </div>
@@ -100,6 +100,11 @@ tr.show-more {
100
100
  font-size: 12px;
101
101
  }
102
102
 
103
+ #bottom-panel.full {
104
+ height: 90%;
105
+ border-top: 2px solid black;
106
+ }
107
+
103
108
  .share {
104
109
  position: fixed;
105
110
  bottom: 70px;
@@ -12,7 +12,7 @@ module Logster
12
12
  HTTP_X_REAL_IP
13
13
  }
14
14
 
15
- attr_accessor :timestamp, :severity, :progname, :message, :key, :backtrace, :count, :env
15
+ attr_accessor :timestamp, :severity, :progname, :message, :key, :backtrace, :count, :env, :protected
16
16
 
17
17
  def initialize(severity, progname, message, timestamp = nil, key = nil)
18
18
  @timestamp = timestamp || get_timestamp
@@ -22,6 +22,7 @@ module Logster
22
22
  @key = key || SecureRandom.hex
23
23
  @backtrace = nil
24
24
  @count = 1
25
+ @protected = false
25
26
  end
26
27
 
27
28
  def to_h
@@ -33,7 +34,8 @@ module Logster
33
34
  key: @key,
34
35
  backtrace: @backtrace,
35
36
  count: @count,
36
- env: @env
37
+ env: @env,
38
+ protected: @protected
37
39
  }
38
40
  end
39
41
 
@@ -39,16 +39,27 @@ module Logster
39
39
  @fileserver.call(env)
40
40
  elsif resource.start_with?("/messages.json")
41
41
  serve_messages(Rack::Request.new(env))
42
- elsif resource =~ /\/protect\/([0-9a-f]+)$/
43
- key = $1
44
- if env[REQUEST_METHOD] == "PUT"
45
- Logster.store.protect(key)
46
- return [200, {"Content-Type" => "text/plain; charset=utf-8"}, ["OK"]]
47
- elsif env[REQUEST_METHOD] == "DELETE"
48
- Logster.store.unprotect(key)
49
- return [200, {"Content-Type" => "text/plain; charset=utf-8"}, ["OK"]]
42
+ elsif resource =~ /\/(un)?protect\/([0-9a-f]+)$/
43
+ off = $1 == "un"
44
+ key = $2
45
+
46
+ message = Logster.store.get(key)
47
+ unless message
48
+ return [404, {}, ["Message not found"]]
49
+ end
50
+
51
+ if off
52
+ if Logster.store.unprotect(key)
53
+ return [301, {"Location" => "#{@logs_path}/show/#{key}?protected=false"}, []]
54
+ else
55
+ return [500, {}, ["Failed"]]
56
+ end
50
57
  else
51
- return [405, {}, ["Only PUT and DELETE are supported for this URL"]]
58
+ if Logster.store.protect(key)
59
+ return [301, {"Location" => "#{@logs_path}/show/#{key}?protected=true"}, []]
60
+ else
61
+ return [500, {}, ["Failed"]]
62
+ end
52
63
  end
53
64
  elsif resource =~ /\/show\/([0-9a-f]+)(\.json)?$/
54
65
  key = $1
@@ -122,15 +122,18 @@ module Logster
122
122
  json = @redis.hget(hash_key, message_key)
123
123
  return nil unless json
124
124
 
125
- Message.from_json(json)
125
+ message = Message.from_json(json)
126
+ message.protected = @redis.sismember(protected_key, message_key)
127
+ message
126
128
  end
127
129
 
128
130
  def protect(message_key)
129
- index = find_message(list_key, message_key)
130
- # can't save something we already lost
131
- return false unless index
131
+ json = @redis.hget(hash_key, message_key)
132
+ # Message already lost
133
+ return false unless json
132
134
 
133
135
  @redis.sadd(protected_key, message_key)
136
+
134
137
  true
135
138
  end
136
139
 
@@ -1,3 +1,3 @@
1
1
  module Logster
2
- VERSION = "0.0.11"
2
+ VERSION = "0.0.12"
3
3
  end
@@ -108,10 +108,12 @@ class TestRedisStore < Minitest::Test
108
108
 
109
109
  # Saved messages still accessible by key
110
110
  assert_equal("B", @store.get(b_message.key).message)
111
+ assert_equal(true, @store.get(b_message.key).protected)
111
112
 
112
113
  # Unsave does not delete message if still recent
113
114
  @store.unprotect c_message.key
114
115
  assert_equal("C", @store.get(c_message.key).message)
116
+ assert_equal(false, @store.get(c_message.key).protected)
115
117
 
116
118
  # Unsave *does* delete message if not recent
117
119
  @store.unprotect b_message.key
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.0.11
4
+ version: 0.0.12
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-02 00:00:00.000000000 Z
11
+ date: 2014-07-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler