Module: ActionMCP::Logging
- Defined in:
- lib/action_mcp/logging.rb,
lib/action_mcp/logging/level.rb,
lib/action_mcp/logging/mixin.rb,
lib/action_mcp/logging/state.rb,
lib/action_mcp/logging/logger.rb,
lib/action_mcp/logging/null_logger.rb
Overview
Global MCP logging interface
Defined Under Namespace
Modules: Mixin Classes: Level, Logger, NullLogger, State
Class Method Summary collapse
-
.disable! ⇒ Boolean
Disable MCP logging.
-
.enable! ⇒ Boolean
Enable MCP logging.
-
.enabled? ⇒ Boolean
Check if logging is enabled.
-
.initialize_from_config! ⇒ Object
Initialize logging state based on configuration.
-
.level ⇒ Symbol
Get the current minimum log level.
-
.level=(new_level) ⇒ Symbol
(also: set_level)
Set the minimum log level.
-
.logger(name: nil, session:) ⇒ ActionMCP::Logging::Logger, ActionMCP::Logging::NullLogger
Create a logger for the given session.
-
.logger_for_context(name: nil, execution_context:) ⇒ ActionMCP::Logging::Logger, ActionMCP::Logging::NullLogger
Convenience method to get a logger for the current session context.
-
.reset! ⇒ void
Reset the global state (for testing).
-
.state ⇒ ActionMCP::Logging::State
Get the global logging state.
Class Method Details
.disable! ⇒ Boolean
Disable MCP logging
38 39 40 |
# File 'lib/action_mcp/logging.rb', line 38 def disable! state.disable! end |
.enable! ⇒ Boolean
Enable MCP logging
31 32 33 34 |
# File 'lib/action_mcp/logging.rb', line 31 def enable! ActionMCP.configuration.logging_enabled = true state.enable! end |
.enabled? ⇒ Boolean
Check if logging is enabled
25 26 27 |
# File 'lib/action_mcp/logging.rb', line 25 def enabled? ActionMCP.configuration.logging_enabled && state.enabled? end |
.initialize_from_config! ⇒ Object
Initialize logging state based on configuration
82 83 84 85 86 87 88 89 90 91 |
# File 'lib/action_mcp/logging.rb', line 82 def self.initialize_from_config! # Always set the level from configuration state.level = ActionMCP.configuration.logging_level if ActionMCP.configuration.logging_enabled state.enable! else state.disable! end end |
.level ⇒ Symbol
Get the current minimum log level
44 45 46 |
# File 'lib/action_mcp/logging.rb', line 44 def level state.level_symbol end |
.level=(new_level) ⇒ Symbol Also known as: set_level
Set the minimum log level
51 52 53 54 |
# File 'lib/action_mcp/logging.rb', line 51 def level=(new_level) state.level = new_level state.level_symbol end |
.logger(name: nil, session:) ⇒ ActionMCP::Logging::Logger, ActionMCP::Logging::NullLogger
Create a logger for the given session
61 62 63 64 65 66 67 |
# File 'lib/action_mcp/logging.rb', line 61 def logger(name: nil, session:) if enabled? Logger.new(name: name, session: session, state: state) else NullLogger.new end end |
.logger_for_context(name: nil, execution_context:) ⇒ ActionMCP::Logging::Logger, ActionMCP::Logging::NullLogger
Convenience method to get a logger for the current session context
73 74 75 76 77 78 |
# File 'lib/action_mcp/logging.rb', line 73 def logger_for_context(name: nil, execution_context:) session = execution_context[:session] return NullLogger.new unless session logger(name: name, session: session) end |
.reset! ⇒ void
This method returns an undefined value.
Reset the global state (for testing)
19 20 21 |
# File 'lib/action_mcp/logging.rb', line 19 def reset! @state = State.new end |
.state ⇒ ActionMCP::Logging::State
Get the global logging state
13 14 15 |
# File 'lib/action_mcp/logging.rb', line 13 def state @state ||= State.new end |