Module: LogBox
- Defined in:
- lib/log_box.rb,
lib/log_box/version.rb
Constant Summary collapse
- DEFAULT_TAG =
:thread- VERSION =
"0.0.2"
Class Method Summary collapse
- .display ⇒ Object
-
.flush(options = {}) ⇒ Object
Following log will be stored into fluentd: { “_id” : ObjectId(“52c4a1f4e1eef37b9900001a”), “tag” : “delayed_job”, “logs” : [ { “time” : “2014-01-01 15:16:43 -0800”, “log” : “Ho-ho”, “priority” : 3 } ], “time” : ISODate(“2014-01-01T23:17:01.000Z”) }.
- .log(obj, options = {}) ⇒ Object
- .log_box ⇒ Object
Class Method Details
.display ⇒ Object
37 38 39 |
# File 'lib/log_box.rb', line 37 def self.display pp log_box end |
.flush(options = {}) ⇒ Object
Following log will be stored into fluentd: {
"_id" : ObjectId("52c4a1f4e1eef37b9900001a"),
"tag" : "delayed_job",
"logs" : [
{
"time" : "2014-01-01 15:16:43 -0800",
"log" : "Ho-ho",
"priority" : 3
}
],
"time" : ISODate("2014-01-01T23:17:01.000Z")
}
29 30 31 32 33 34 35 |
# File 'lib/log_box.rb', line 29 def self.flush( = {}) o = { tag: DEFAULT_TAG }.merge() tag = o[:tag] o[:logs] = log_box[tag] flush_to_fluentd o delete_log_box_tag tag end |
.log(obj, options = {}) ⇒ Object
8 9 10 11 12 13 |
# File 'lib/log_box.rb', line 8 def self.log(obj, = {}) o = { tag: DEFAULT_TAG, time: current_time, log: obj }.merge() tag = o.delete :tag init_log_box_tag_if_not tag log_box[tag] << o end |
.log_box ⇒ Object
41 42 43 |
# File 'lib/log_box.rb', line 41 def self.log_box Thread.current[:_log_box] end |