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 +4 -4
- data/assets/javascript/app.js +19 -13
- data/assets/javascript/components/message-info.handlebars +7 -5
- data/assets/javascript/templates/show.handlebars +1 -3
- data/assets/stylesheets/app.css +5 -0
- data/lib/logster/message.rb +4 -2
- data/lib/logster/middleware/viewer.rb +20 -9
- data/lib/logster/redis_store.rb +7 -4
- data/lib/logster/version.rb +1 -1
- data/test/logster/test_redis_store.rb +2 -0
- metadata +2 -2
    
        checksums.yaml
    CHANGED
    
    | @@ -1,7 +1,7 @@ | |
| 1 1 | 
             
            ---
         | 
| 2 2 | 
             
            SHA1:
         | 
| 3 | 
            -
              metadata.gz:  | 
| 4 | 
            -
              data.tar.gz:  | 
| 3 | 
            +
              metadata.gz: b21c5ac2f54261afd0a6b2b35bff091e19b8c585
         | 
| 4 | 
            +
              data.tar.gz: 2f14a5000271e1017c380379cbcf377025747eda
         | 
| 5 5 | 
             
            SHA512:
         | 
| 6 | 
            -
              metadata.gz:  | 
| 7 | 
            -
              data.tar.gz:  | 
| 6 | 
            +
              metadata.gz: 423e3ed1d419725174e2593f237274821edcc0b904f7286d7e88f0afccc040a321de66a9d410b6e646b153060f0fd094a54fa46c6387e8f418b1c48a49c50994
         | 
| 7 | 
            +
              data.tar.gz: 59143d70c2839be397e98025ae4d66fd4e987e3bc86d7d5c382f851cd4cafa19fc7fc79f7549a85096fa56b8a4ec08cec72221c2fb4857cd2aa5b2bd74eb4856
         | 
    
        data/assets/javascript/app.js
    CHANGED
    
    | @@ -59,12 +59,12 @@ App.Message = Ember.Object.extend({ | |
| 59 59 | 
             
              },
         | 
| 60 60 |  | 
| 61 61 | 
             
              protect: function() {
         | 
| 62 | 
            -
                this.set(' | 
| 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(' | 
| 67 | 
            -
                return App.ajax("/ | 
| 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 | 
            -
                    {{ | 
| 8 | 
            -
             | 
| 9 | 
            -
             | 
| 10 | 
            -
             | 
| 11 | 
            -
             | 
| 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}}
         | 
    
        data/assets/stylesheets/app.css
    CHANGED
    
    
    
        data/lib/logster/message.rb
    CHANGED
    
    | @@ -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 | 
            -
                         | 
| 44 | 
            -
                         | 
| 45 | 
            -
             | 
| 46 | 
            -
             | 
| 47 | 
            -
                         | 
| 48 | 
            -
                           | 
| 49 | 
            -
             | 
| 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 | 
            -
                           | 
| 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
         | 
    
        data/lib/logster/redis_store.rb
    CHANGED
    
    | @@ -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 | 
            -
                   | 
| 130 | 
            -
                  #  | 
| 131 | 
            -
                  return false unless  | 
| 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 |  | 
    
        data/lib/logster/version.rb
    CHANGED
    
    
| @@ -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. | 
| 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- | 
| 11 | 
            +
            date: 2014-07-04 00:00:00.000000000 Z
         | 
| 12 12 | 
             
            dependencies:
         | 
| 13 13 | 
             
            - !ruby/object:Gem::Dependency
         | 
| 14 14 | 
             
              name: bundler
         |