kcaco 0.0.1 → 0.0.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.
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- kcaco (0.0.1)
4
+ kcaco (0.0.2)
5
5
  guid
6
6
 
7
7
  GEM
data/README.md CHANGED
@@ -42,6 +42,25 @@ write out the exception object to `Kcaco.save_path` in a file named
42
42
  the same as that GUID. You can disable the save behavior with
43
43
  `Kcaco.auto_save = false`.
44
44
 
45
+ ### Payloads
46
+
47
+ If you have additional information to store, you can do so by parsing
48
+ in a payload with the block syntax (`examples/block.rb`).
49
+
50
+ ```ruby
51
+ Kcaco.pretty(exception) { "payload" }
52
+ ```
53
+
54
+ This will not affect the logged message but will write out the payload
55
+ in the saved exception. This can be useful if you want to store
56
+ state. For example, if your application is processing a queue and you
57
+ got an exception, you could store the queue message that triggered the
58
+ error in the payload for later debugging.
59
+
60
+ ### Customize log message
61
+
62
+ TBD.
63
+
45
64
  ## Example
46
65
 
47
66
  $ bundle exec examples/simple.rb
@@ -109,14 +128,15 @@ have to run with verbose logging:
109
128
  D, [2012-01-06T16:28:33.903784 #736] DEBUG -- : examples/no_kcaco_different_levels.rb:10:in `explosions'
110
129
  D, [2012-01-06T16:28:33.903814 #736] DEBUG -- : examples/no_kcaco_different_levels.rb:17
111
130
 
112
- Or you can roll your own smarts. Repeatedly. Or just use some like Kcaco. Quite simply what it does is:
131
+ Or you can roll your own smarts. Repeatedly. Or just use something
132
+ like Kcaco. Quite simply what it does is:
113
133
 
114
134
  * Save you having to format the log message by doing it for you.
115
135
  * Write more detail to a separate file where you can inspect it later.
116
136
 
117
137
  .. and you get
118
138
 
119
- bundle exec examples/simple.rb
139
+ $ bundle exec examples/simple.rb
120
140
  E, [2012-01-06T16:29:50.730922 #793] ERROR -- : ae58d80f-4bc3-899a-fd0b-2c831833510c MichaelBay::Boom: ba da bloom [simple.rb L11]
121
141
 
122
142
  In this example, you could see the saved exception
data/examples/block.rb ADDED
@@ -0,0 +1,22 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "logger"
4
+ require "kcaco"
5
+
6
+ class MichaelBay
7
+
8
+ class Boom < RuntimeError; end
9
+
10
+ def explosions
11
+ raise Boom.new("ba da bloom")
12
+ end
13
+ end
14
+
15
+ if __FILE__ == $0
16
+ logger = Logger.new(STDOUT)
17
+ begin
18
+ MichaelBay.new.explosions
19
+ rescue => e
20
+ logger.error Kcaco.pretty(e) { "custom payload" }
21
+ end
22
+ end
data/lib/kcaco.rb CHANGED
@@ -34,6 +34,7 @@ module Kcaco
34
34
 
35
35
  def pretty(exception)
36
36
  wrapped_exception = Kcaco::WrappedException.new(exception)
37
+ wrapped_exception.payload = yield if block_given?
37
38
  save(wrapped_exception) if auto_save?
38
39
  wrapped_exception.pretty
39
40
  end
@@ -20,6 +20,7 @@ module Kcaco
20
20
  ["time", Time.now.iso8601],
21
21
  ["type", exception.type],
22
22
  ["message", exception.message],
23
+ ["payload", exception.payload],
23
24
  ].each do |label, text|
24
25
  f.puts([label, text].join(": "))
25
26
  end
data/lib/kcaco/version.rb CHANGED
@@ -1,7 +1,7 @@
1
1
  module Kcaco
2
2
 
3
3
  def version
4
- "0.0.1"
4
+ "0.0.2"
5
5
  end
6
6
  module_function :version
7
7
  end
@@ -4,7 +4,7 @@ module Kcaco
4
4
  require "guid"
5
5
 
6
6
 
7
- attr_accessor :exception
7
+ attr_accessor :exception, :payload
8
8
 
9
9
  def initialize(exception)
10
10
  self.exception = exception
Binary file
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: kcaco
3
3
  version: !ruby/object:Gem::Version
4
- hash: 29
4
+ hash: 27
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 0
9
- - 1
10
- version: 0.0.1
9
+ - 2
10
+ version: 0.0.2
11
11
  platform: ruby
12
12
  authors:
13
13
  - Marc Bowes
@@ -71,10 +71,12 @@ extra_rdoc_files: []
71
71
 
72
72
  files:
73
73
  - examples/no_kcaco_different_levels.rb
74
+ - examples/block.rb
74
75
  - examples/simple.rb
75
76
  - examples/no_kcaco_one_line.rb
76
77
  - Rakefile
77
78
  - README.md
79
+ - pkg/kcaco-0.0.1.gem
78
80
  - Gemfile
79
81
  - kcaco.gemspec
80
82
  - spec/support/boom.rb