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.
-
#level_threshold ⇒ Object
Returns the value of attribute level_threshold.
-
#level_threshold_broken ⇒ Object
Returns the value of attribute level_threshold_broken.
-
#name ⇒ Object
Returns the value of attribute name.
-
#parent ⇒ Object
readonly
Returns the value of attribute parent.
Instance Method Summary collapse
-
#initialize(options, lmbda) ⇒ Transaction
constructor
A new instance of Transaction.
-
#log(message, level = :info) ⇒ Object
Pushes a message into the log queue.
Constructor Details
#initialize(options, lmbda) ⇒ Transaction
Returns a new instance of Transaction.
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/transaction_logger/transaction.rb', line 16 def initialize(, lmbda) @parent = [:parent] @parent.log self if @parent @lmbda = lmbda @log_prefix = [:prefix] @name = "undefined" @context = {} @level_threshold = [:level_threshold] || :error @log_queue = [] @start = Time.now @error_printed = nil @level_threshold_broken = false @logger = [:logger] end |
Instance Attribute Details
#context ⇒ Object
Returns the value of attribute context.
9 10 11 |
# File 'lib/transaction_logger/transaction.rb', line 9 def context @context end |
#level_threshold ⇒ Object
Returns the value of attribute level_threshold.
10 11 12 |
# File 'lib/transaction_logger/transaction.rb', line 10 def level_threshold @level_threshold end |
#level_threshold_broken ⇒ Object
Returns the value of attribute level_threshold_broken.
11 12 13 |
# File 'lib/transaction_logger/transaction.rb', line 11 def level_threshold_broken @level_threshold_broken end |
#name ⇒ Object
Returns the value of attribute name.
8 9 10 |
# File 'lib/transaction_logger/transaction.rb', line 8 def name @name end |
#parent ⇒ Object (readonly)
Returns the value of attribute parent.
6 7 8 |
# File 'lib/transaction_logger/transaction.rb', line 6 def parent @parent end |
Instance Method Details
#log(message, level = :info) ⇒ 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.
66 67 68 69 70 71 72 73 74 75 |
# File 'lib/transaction_logger/transaction.rb', line 66 def log(, level=:info) check_level(level) if .is_a? String = "#{@log_prefix}#{level}" = { => } @log_queue.push else @log_queue.push end end |