bixby-common 0.3.10 → 0.3.11

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.3.10
1
+ 0.3.11
data/bixby-common.gemspec CHANGED
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = "bixby-common"
8
- s.version = "0.3.10"
8
+ s.version = "0.3.11"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Chetan Sarva"]
12
- s.date = "2013-05-16"
12
+ s.date = "2013-05-18"
13
13
  s.description = "Bixby Common files/libs"
14
14
  s.email = "chetan@pixelcop.net"
15
15
  s.files = [
@@ -36,6 +36,7 @@ Gem::Specification.new do |s|
36
36
  "lib/bixby_common/util/http_client.rb",
37
37
  "lib/bixby_common/util/jsonify.rb",
38
38
  "lib/bixby_common/util/log.rb",
39
+ "lib/bixby_common/util/log/filtering_layout.rb",
39
40
  "test/bixby_common_test.rb",
40
41
  "test/command_response_test.rb",
41
42
  "test/command_spec_test.rb",
@@ -0,0 +1,59 @@
1
+
2
+ module Bixby
3
+ module Log
4
+
5
+ class FilteringLayout < Logging::Layouts::Pattern
6
+
7
+ # Filter the exception if a block is available
8
+ #
9
+ # @param [Exception] ex
10
+ #
11
+ # @return [Array<String>] backtrace
12
+ def filter_ex(ex)
13
+ if @filter.nil? then
14
+ return ex.backtrace
15
+ end
16
+
17
+ return @filter.call(ex)
18
+ end
19
+
20
+ # Set the exception filter
21
+ #
22
+ # @param [Block] block
23
+ # @yield [Exception] the exception to filter
24
+ def set_filter(&block)
25
+ @filter = block
26
+ end
27
+
28
+ # Return a string representation of the given object. Depending upon
29
+ # the configuration of the logger system the format will be an +inspect+
30
+ # based representation or a +yaml+ based representation.
31
+ #
32
+ # @param [Object] obj
33
+ #
34
+ # @return [String]
35
+ def format_obj( obj )
36
+ case obj
37
+ when String; obj
38
+ when Exception
39
+ str = "<#{obj.class.name}> #{obj.message}"
40
+ if @backtrace && !obj.backtrace.nil?
41
+ str << "\n\t" << filter_ex(obj).join("\n\t")
42
+ end
43
+ str
44
+ when nil; "<#{obj.class.name}> nil"
45
+ else
46
+ str = "<#{obj.class.name}> "
47
+ str << case @obj_format
48
+ when :inspect; obj.inspect
49
+ when :yaml; try_yaml(obj)
50
+ when :json; try_json(obj)
51
+ else obj.to_s end
52
+ str
53
+ end
54
+ end
55
+
56
+ end
57
+
58
+ end
59
+ end
@@ -1,6 +1,8 @@
1
1
 
2
2
  require "logging"
3
3
 
4
+ require "bixby_common/util/log/filtering_layout"
5
+
4
6
  module Bixby
5
7
 
6
8
  # A simple logging mixin
metadata CHANGED
@@ -2,14 +2,14 @@
2
2
  name: bixby-common
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 0.3.10
5
+ version: 0.3.11
6
6
  platform: ruby
7
7
  authors:
8
8
  - Chetan Sarva
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-05-16 00:00:00.000000000 Z
12
+ date: 2013-05-18 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: multi_json
@@ -408,6 +408,7 @@ files:
408
408
  - lib/bixby_common/util/http_client.rb
409
409
  - lib/bixby_common/util/jsonify.rb
410
410
  - lib/bixby_common/util/log.rb
411
+ - lib/bixby_common/util/log/filtering_layout.rb
411
412
  - test/bixby_common_test.rb
412
413
  - test/command_response_test.rb
413
414
  - test/command_spec_test.rb
@@ -430,7 +431,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
430
431
  requirements:
431
432
  - - ! '>='
432
433
  - !ruby/object:Gem::Version
433
- hash: -1667581609751385562
434
+ hash: -2563204950975806238
434
435
  segments:
435
436
  - 0
436
437
  version: '0'