Class: TransactionLogger::Transaction
- Inherits:
-
Object
- Object
- TransactionLogger::Transaction
- Defined in:
- lib/transaction_logger/transaction.rb
Instance Attribute Summary collapse
-
#context ⇒ Object
Returns the value of attribute context.
-
#name ⇒ Object
Returns the value of attribute name.
-
#parent ⇒ Object
readonly
Returns the value of attribute parent.
Instance Method Summary collapse
-
#initialize(parent = nil, lmbda) ⇒ Transaction
constructor
A new instance of Transaction.
-
#log(message) ⇒ Object
Pushes a message into the log queue.
Constructor Details
#initialize(parent = nil, lmbda) ⇒ Transaction
Returns a new instance of Transaction.
11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/transaction_logger/transaction.rb', line 11 def initialize(parent=nil, lmbda) @parent = parent @parent.log self if @parent @lmbda = lmbda @name = "undefined" @context = {} @log_queue = Array.new @start = Time.now @error_printed = nil end |
Instance Attribute Details
#context ⇒ Object
Returns the value of attribute context.
6 7 8 |
# File 'lib/transaction_logger/transaction.rb', line 6 def context @context end |
#name ⇒ Object
Returns the value of attribute name.
5 6 7 |
# File 'lib/transaction_logger/transaction.rb', line 5 def name @name end |
#parent ⇒ Object (readonly)
Returns the value of attribute parent.
3 4 5 |
# File 'lib/transaction_logger/transaction.rb', line 3 def parent @parent end |
Instance Method Details
#log(message) ⇒ Object
Pushes a message into the log queue. Logs are stored in order of time logged. Note that this method will not output a log, but just stores it in the queue to be outputted if an error is raised in a transaction.
58 59 60 61 62 63 64 65 66 |
# File 'lib/transaction_logger/transaction.rb', line 58 def log() if .is_a? String = "#{TransactionLogger.log_prefix}info" = { => } @log_queue.push else @log_queue.push end end |