Class: RubynCode::Hooks::BuiltIn::LoggingHook
- Inherits:
-
Object
- Object
- RubynCode::Hooks::BuiltIn::LoggingHook
- Defined in:
- lib/rubyn_code/hooks/built_in.rb
Overview
Logs tool calls and their results via the formatter.
Listens to :pre_tool_use and :post_tool_use events.
Instance Method Summary collapse
-
#call(tool_name:, tool_input: {}, result: nil, **_kwargs) ⇒ nil
Handles both :pre_tool_use and :post_tool_use events.
-
#initialize(formatter:) ⇒ LoggingHook
constructor
A new instance of LoggingHook.
Constructor Details
#initialize(formatter:) ⇒ LoggingHook
Returns a new instance of LoggingHook.
53 54 55 |
# File 'lib/rubyn_code/hooks/built_in.rb', line 53 def initialize(formatter:) @formatter = formatter end |
Instance Method Details
#call(tool_name:, tool_input: {}, result: nil, **_kwargs) ⇒ nil
Handles both :pre_tool_use and :post_tool_use events.
For :pre_tool_use, logs the tool name and input arguments. For :post_tool_use, logs the tool result.
67 68 69 70 71 72 73 74 75 |
# File 'lib/rubyn_code/hooks/built_in.rb', line 67 def call(tool_name:, tool_input: {}, result: nil, **_kwargs) if result.nil? @formatter.tool_call(tool_name, tool_input) else @formatter.tool_result(tool_name, result, success: true) end nil end |