Class: Google::Cloud::Debugger::Logpoint

Inherits:
Breakpoint
  • Object
show all
Defined in:
lib/google/cloud/debugger/logpoint.rb

Overview

Logpoint

A kind of Breakpoint that can be evaluated to generate a formatted log string, which later can be submitted to Stackdriver Logging service

Instance Attribute Summary

Attributes inherited from Breakpoint

#action, #app_root, #condition, #create_time, #evaluated_expressions, #evaluated_log_message, #expressions, #final_time, #id, #is_final_state, #labels, #location, #log_level, #log_message_format, #stack_frames, #status, #user_email, #variable_table

Instance Method Summary collapse

Methods inherited from Breakpoint

#check_condition, #complete, #complete?, #eql?, #full_path, #line, #path, #set_error_state, #valid?

Instance Method Details

#evaluate(call_stack_bindings) ⇒ Boolean

Evaluate the breakpoint unless it's already marked as completed. Store evaluted expressions and stack frame variables in @evaluated_expressions and @evaluated_log_message.

Parameters:

  • call_stack_bindings (Array<Binding>)

    An array of Ruby Binding objects, from the call stack that leads to the triggering of the breakpoints.

Returns:

  • (Boolean)

    True if evaluated successfully; false otherwise.



40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
# File 'lib/google/cloud/debugger/logpoint.rb', line 40

def evaluate call_stack_bindings
  synchronize do
    binding = call_stack_bindings[0]

    return false if complete? || !check_condition(binding)

    begin
      evaluate_log_message binding
    rescue
      return false
    end
  end

  true
end