Class: VCAP::Logging::LogRecord
- Inherits:
-
Object
- Object
- VCAP::Logging::LogRecord
- Defined in:
- lib/vcap/logging/log_record.rb
Constant Summary collapse
- @@have_fibers =
nil
Instance Attribute Summary collapse
-
#data ⇒ Object
readonly
Returns the value of attribute data.
-
#fiber_id ⇒ Object
readonly
Returns the value of attribute fiber_id.
-
#fiber_shortid ⇒ Object
readonly
Returns the value of attribute fiber_shortid.
-
#log_level ⇒ Object
readonly
Returns the value of attribute log_level.
-
#logger_name ⇒ Object
readonly
Returns the value of attribute logger_name.
-
#process_id ⇒ Object
readonly
Returns the value of attribute process_id.
-
#tags ⇒ Object
readonly
Returns the value of attribute tags.
-
#thread_id ⇒ Object
readonly
Returns the value of attribute thread_id.
-
#thread_shortid ⇒ Object
readonly
Returns the value of attribute thread_shortid.
-
#timestamp ⇒ Object
readonly
Returns the value of attribute timestamp.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(log_level, data, logger, tags = []) ⇒ LogRecord
constructor
A new instance of LogRecord.
Constructor Details
#initialize(log_level, data, logger, tags = []) ⇒ LogRecord
Returns a new instance of LogRecord.
47 48 49 50 51 52 53 54 55 56 57 58 59 |
# File 'lib/vcap/logging/log_record.rb', line 47 def initialize(log_level, data, logger, =[]) @timestamp = Time.now @data = data @logger_name = logger.name @log_level = log_level @tags = @thread_id = Thread.current.object_id @thread_shortid = shortid(@thread_id) @fiber_id = LogRecord.current_fiber_id @fiber_shortid = @fiber_id ? shortid(@fiber_id) : nil @process_id = Process.pid end |
Instance Attribute Details
#data ⇒ Object (readonly)
Returns the value of attribute data.
37 38 39 |
# File 'lib/vcap/logging/log_record.rb', line 37 def data @data end |
#fiber_id ⇒ Object (readonly)
Returns the value of attribute fiber_id.
43 44 45 |
# File 'lib/vcap/logging/log_record.rb', line 43 def fiber_id @fiber_id end |
#fiber_shortid ⇒ Object (readonly)
Returns the value of attribute fiber_shortid.
44 45 46 |
# File 'lib/vcap/logging/log_record.rb', line 44 def fiber_shortid @fiber_shortid end |
#log_level ⇒ Object (readonly)
Returns the value of attribute log_level.
38 39 40 |
# File 'lib/vcap/logging/log_record.rb', line 38 def log_level @log_level end |
#logger_name ⇒ Object (readonly)
Returns the value of attribute logger_name.
39 40 41 |
# File 'lib/vcap/logging/log_record.rb', line 39 def logger_name @logger_name end |
#process_id ⇒ Object (readonly)
Returns the value of attribute process_id.
45 46 47 |
# File 'lib/vcap/logging/log_record.rb', line 45 def process_id @process_id end |
#tags ⇒ Object (readonly)
Returns the value of attribute tags.
40 41 42 |
# File 'lib/vcap/logging/log_record.rb', line 40 def @tags end |
#thread_id ⇒ Object (readonly)
Returns the value of attribute thread_id.
41 42 43 |
# File 'lib/vcap/logging/log_record.rb', line 41 def thread_id @thread_id end |
#thread_shortid ⇒ Object (readonly)
Returns the value of attribute thread_shortid.
42 43 44 |
# File 'lib/vcap/logging/log_record.rb', line 42 def thread_shortid @thread_shortid end |
#timestamp ⇒ Object (readonly)
Returns the value of attribute timestamp.
36 37 38 |
# File 'lib/vcap/logging/log_record.rb', line 36 def @timestamp end |
Class Method Details
.current_fiber_id ⇒ Object
26 27 28 29 30 31 32 |
# File 'lib/vcap/logging/log_record.rb', line 26 def current_fiber_id if have_fibers? Fiber.current.object_id else nil end end |
.have_fibers? ⇒ Boolean
13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/vcap/logging/log_record.rb', line 13 def have_fibers? if @@have_fibers == nil begin require 'fiber' @@have_fibers = true rescue LoadError @@have_fibers = false end else @@have_fibers end end |