logster 0.0.3 → 0.0.4

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: 2dad3528f0f66416dd6be075bc89aa5a143a6cc0
4
- data.tar.gz: 6d187ba9d934f8fc1ba770cb1edf67c1e2d22fbc
3
+ metadata.gz: 4b23208e3d79e4cb73cbe9e80126b478cf04d6a2
4
+ data.tar.gz: 5b6eadd9d5eebe2c73ca8011fe95adf7f35ae1ff
5
5
  SHA512:
6
- metadata.gz: 3fc3c01b210b3ca0d0b039971122fdce7654b8c59f91cb6ff01dc2ec255f3af7688faf46db7988c3c95f7b3aa7341274dfbc3689628ce871cfea4a0602870d99
7
- data.tar.gz: 50271d90874e29781082f723017f121745793ef36fcf7c886b53da7e69549a8bdb53998c3d70088c46e08d917aafdcf67b420e1800e09fee2c212535658a3ccd
6
+ metadata.gz: 048c85e54a50b34845fb61cf9c9c59c22e7f35833713636b5a03f408f58a319bd34474f6c0aa034730308ace8b20f886bb14e3818e16573846ef8e0731ae5260
7
+ data.tar.gz: e98d6c25f00340deae55c94ad6f5d929e3df88d8a287e8a0bcf9d6fb4fd0407f0b111bf6f5cac1a30a918a34f1d648054cd993c9b429b46908e4ce97599202bc
data/README.md CHANGED
@@ -42,3 +42,6 @@ Logster UI is built using [Ember.js](http://emberjs.com/)
42
42
  # CHANGELOG
43
43
 
44
44
  - 2014-05-07: Started changelog :)
45
+ - 2014-05-07: Version 0.0.4
46
+ - Feature: Ability to ignore patterns with Logster.store.ignore = [/regex/]
47
+ - Feature: Store backtraces, allow people to view them in the GUI
@@ -415,3 +415,34 @@ Handlebars.registerHelper('timeAgo', function(prop, options){
415
415
 
416
416
  return new Handlebars.SafeString(formatted);
417
417
  });
418
+
419
+
420
+ App.TabbedSectionComponent = Ember.Component.extend({
421
+ selectTab: function(view){
422
+ var selected = this.get("selected");
423
+ if(selected){
424
+ selected.set("active",false);
425
+ }
426
+ this.set("selected", view);
427
+ view.set("active", true);
428
+ },
429
+ tabs: function(){
430
+ var result = [],
431
+ first = true,
432
+ self = this;
433
+
434
+ this.get("childViews").forEach(function(view){
435
+ if(view.constructor + "" === "App.TabContentsComponent"){
436
+ result.push(view);
437
+ if(first){
438
+ self.selectTab(view);
439
+ first = false;
440
+ }
441
+ }
442
+ });
443
+ return result;
444
+ }.property()
445
+ });
446
+ App.TabContentsComponent = Ember.Component.extend({
447
+ classNameBindings: ["active", ":content"]
448
+ });
@@ -0,0 +1,6 @@
1
+ {{yield}}
2
+ <ul class="tabs">
3
+ {{#each tab in tabs}}
4
+ <li><a {{bind-attr title="tab.hint"}} href="#" {{bind-attr class="tab.active"}} {{action selectTab tab}}>{{tab.name}}</a></li>
5
+ {{/each}}
6
+ </ul>
@@ -20,7 +20,10 @@
20
20
  <div id="divider"></div>
21
21
  <div id="bottom-panel">
22
22
  <div class="message-info">
23
- <pre>{{currentMessage.message}}</pre>
23
+ {{#tabbed-section}}
24
+ {{#tab-contents name="info" hint="show info"}}<pre>{{currentMessage.message}}</pre>{{/tab-contents}}
25
+ {{#tab-contents name="backtrace" hint="show backtrace"}}<pre>{{currentMessage.backtrace}}</pre>{{/tab-contents}}
26
+ {{/tabbed-section}}
24
27
  </div>
25
28
 
26
29
  <div class="action-panel">
@@ -193,3 +193,52 @@ tr.show-more {
193
193
  cursor: row-resize;
194
194
  opacity: 0;
195
195
  }
196
+
197
+ .message-info .content {
198
+ position: absolute;
199
+ top: 5;
200
+ bottom: 40;
201
+ left: 5;
202
+ right: 5;
203
+ overflow: auto;
204
+ display: none;
205
+ }
206
+
207
+ .message-info .content.active {
208
+ display: block;
209
+ }
210
+
211
+
212
+ .tabs {
213
+ position: absolute;
214
+ bottom: 10;
215
+ left: 0;
216
+ right: 0;
217
+ list-style-type: none;
218
+ border-top: 1px solid #ddd;
219
+ margin: 0 0 5px;
220
+ padding: 0 0 0 14px;
221
+ }
222
+ .tabs li {
223
+ float: left;
224
+ position: relative;
225
+ padding-right: 5px;
226
+ margin: 0;
227
+ }
228
+ .tabs a {
229
+ position: relative;
230
+ top: 4px;
231
+ text-decoration: none;
232
+ color: #333;
233
+ border: 1px solid #ddd;
234
+ border-top: none;
235
+ border-bottom-left-radius: 5px;
236
+ border-bottom-right-radius: 5px;
237
+ padding: 4px;
238
+ background-color: #e1e1e1;
239
+ }
240
+
241
+ .tabs a.active{
242
+ border-top: 1px solid #f1f1f1;
243
+ background-color: #f1f1f1;
244
+ }
@@ -0,0 +1,24 @@
1
+ {
2
+ "name": "logster",
3
+ "version": "0.0.3",
4
+ "homepage": "https://github.com/SamSaffron/logster",
5
+ "description": "logging framework and viewer",
6
+ "authors": [
7
+ "Sam Saffron"
8
+ ],
9
+ "license": "MIT",
10
+ "private": true,
11
+ "ignore": [
12
+ "**/.*",
13
+ "node_modules",
14
+ "bower_components",
15
+ "test",
16
+ "tests"
17
+ ],
18
+ "dependencies": {
19
+ "ember": "~1.5.1",
20
+ "lodash": "~2.4.1",
21
+ "moment": "~2.6.0",
22
+ "qunit": "~1.14.0"
23
+ }
24
+ }
@@ -1,6 +1,6 @@
1
1
  module Logster
2
2
  class Message
3
- attr_accessor :timestamp, :severity, :progname, :message, :key
3
+ attr_accessor :timestamp, :severity, :progname, :message, :key, :backtrace
4
4
 
5
5
  def initialize(severity, progname, message, timestamp = nil, key = nil)
6
6
  @timestamp = timestamp || get_timestamp
@@ -8,6 +8,7 @@ module Logster
8
8
  @progname = progname
9
9
  @message = message
10
10
  @key = key || SecureRandom.hex
11
+ @backtrace = nil
11
12
  end
12
13
 
13
14
  def to_h
@@ -16,7 +17,8 @@ module Logster
16
17
  progname: @progname,
17
18
  severity: @severity,
18
19
  timestamp: @timestamp,
19
- key: @key
20
+ key: @key,
21
+ backtrace: @backtrace
20
22
  }
21
23
  end
22
24
 
@@ -26,11 +28,13 @@ module Logster
26
28
 
27
29
  def self.from_json(json)
28
30
  parsed = ::JSON.parse(json)
29
- new( parsed["severity"],
31
+ msg = new( parsed["severity"],
30
32
  parsed["progname"],
31
33
  parsed["message"],
32
34
  parsed["timestamp"],
33
35
  parsed["key"] )
36
+ msg.backtrace = parsed["backtrace"]
37
+ msg
34
38
  end
35
39
 
36
40
  protected
@@ -103,8 +103,16 @@ module Logster
103
103
  "<script src='#{@logs_path}/javascript/#{name}'></script>"
104
104
  end
105
105
 
106
+ def component(name)
107
+ ember_template("components/#{name}", "components/" << name)
108
+ end
109
+
106
110
  def handlebars(name)
107
- val = File.read("#{@assets_path}/javascript/templates/#{name}.handlebars")
111
+ ember_template("templates/#{name}", name)
112
+ end
113
+
114
+ def ember_template(location, name)
115
+ val = File.read("#{@assets_path}/javascript/#{location}.handlebars")
108
116
  <<JS
109
117
  <script>
110
118
  Ember.TEMPLATES[#{name.inspect}] = Ember.Handlebars.compile(#{val.inspect});
@@ -125,6 +133,8 @@ JS
125
133
  #{handlebars("application")}
126
134
  #{handlebars("index")}
127
135
  #{handlebars("message")}
136
+ #{component("tabbed-section")}
137
+ #{component("tab-contents")}
128
138
  <script>
129
139
  window.Logger = {
130
140
  rootPath: "#{@logs_path}"
@@ -4,7 +4,8 @@ module Logster
4
4
  class RedisStore
5
5
 
6
6
  attr_accessor :level, :redis, :max_backlog,
7
- :dedup, :max_retention, :skip_empty
7
+ :dedup, :max_retention, :skip_empty,
8
+ :ignore
8
9
 
9
10
  def initialize(redis = nil)
10
11
  @redis = redis || Redis.new
@@ -15,11 +16,19 @@ module Logster
15
16
  end
16
17
 
17
18
 
18
- def report(severity, progname, message)
19
+ def report(severity, progname, message, opts = nil)
19
20
  return if (!message || (String === message && message.empty?)) && skip_empty
20
21
  return if level && severity < level
22
+ return if @ignore && @ignore.any?{|pattern| message =~ pattern}
21
23
 
22
24
  message = Message.new(severity, progname, message)
25
+
26
+ if opts && opts[:backtrace]
27
+ message.backtrace = backtrace
28
+ else
29
+ message.backtrace = caller.join("\n")
30
+ end
31
+
23
32
  @redis.rpush(list_key, message.to_json)
24
33
 
25
34
  # TODO make it atomic
@@ -1,3 +1,3 @@
1
1
  module Logster
2
- VERSION = "0.0.3"
2
+ VERSION = "0.0.4"
3
3
  end
@@ -133,4 +133,18 @@ class TestRedisStore < Minitest::Test
133
133
  assert_equal(1, latest.length)
134
134
  end
135
135
 
136
+ def test_backtrace
137
+ @store.report(Logger::INFO, "test", "pattern_1")
138
+ message = @store.latest(limit: 1).first
139
+ assert_match("test_backtrace", message.backtrace)
140
+ end
141
+
142
+ def test_ignore
143
+ @store.ignore = [/^test/]
144
+ @store.report(Logger::INFO, "test", "test it")
145
+ @store.report(Logger::INFO, "test", " test it")
146
+
147
+ assert_equal(1, @store.latest.count)
148
+ end
149
+
136
150
  end
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.3
4
+ version: 0.0.4
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-05-06 00:00:00.000000000 Z
11
+ date: 2014-05-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -108,6 +108,8 @@ files:
108
108
  - README.md
109
109
  - Rakefile
110
110
  - assets/javascript/app.js
111
+ - assets/javascript/components/tab-contents.handlebars
112
+ - assets/javascript/components/tabbed-section.handlebars
111
113
  - assets/javascript/external/ember.js
112
114
  - assets/javascript/external/ember.min.js
113
115
  - assets/javascript/external/handlebars.min.js
@@ -118,6 +120,7 @@ files:
118
120
  - assets/javascript/templates/index.handlebars
119
121
  - assets/javascript/templates/message.handlebars
120
122
  - assets/stylesheets/app.css
123
+ - bower.json
121
124
  - lib/logster.rb
122
125
  - lib/logster/configuration.rb
123
126
  - lib/logster/logger.rb