Module: ActionMCP::Logging::Mixin

Extended by:
ActiveSupport::Concern
Defined in:
lib/action_mcp/logging/mixin.rb

Overview

Mixin to provide easy MCP logging access for tools, prompts, and resources

Instance Method Summary collapse

Instance Method Details

#mcp_alert(message = nil, data: nil) { ... } ⇒ void

This method returns an undefined value.

Log an alert message

Parameters:

  • message (String, nil) (defaults to: nil)

    The message (if no block given)

  • data (Object) (defaults to: nil)

    Additional structured data

Yields:

  • Block that returns the message (evaluated only if logging)



78
79
80
# File 'lib/action_mcp/logging/mixin.rb', line 78

def mcp_alert(message = nil, data: nil, &block)
  mcp_logger.alert(message, data: data, &block)
end

#mcp_alert?Boolean

Check if alert level is enabled

Returns:

  • (Boolean)

    true if alert messages will be logged



130
131
132
# File 'lib/action_mcp/logging/mixin.rb', line 130

def mcp_alert?
  mcp_logger.alert?
end

#mcp_critical(message = nil, data: nil) { ... } ⇒ void

This method returns an undefined value.

Log a critical message

Parameters:

  • message (String, nil) (defaults to: nil)

    The message (if no block given)

  • data (Object) (defaults to: nil)

    Additional structured data

Yields:

  • Block that returns the message (evaluated only if logging)



69
70
71
# File 'lib/action_mcp/logging/mixin.rb', line 69

def mcp_critical(message = nil, data: nil, &block)
  mcp_logger.critical(message, data: data, &block)
end

#mcp_critical?Boolean

Check if critical level is enabled

Returns:

  • (Boolean)

    true if critical messages will be logged



124
125
126
# File 'lib/action_mcp/logging/mixin.rb', line 124

def mcp_critical?
  mcp_logger.critical?
end

#mcp_debug(message = nil, data: nil) { ... } ⇒ void

This method returns an undefined value.

Log a debug message

Parameters:

  • message (String, nil) (defaults to: nil)

    The message (if no block given)

  • data (Object) (defaults to: nil)

    Additional structured data

Yields:

  • Block that returns the message (evaluated only if logging)



23
24
25
# File 'lib/action_mcp/logging/mixin.rb', line 23

def mcp_debug(message = nil, data: nil, &block)
  mcp_logger.debug(message, data: data, &block)
end

#mcp_debug?Boolean

Check if debug level is enabled

Returns:

  • (Boolean)

    true if debug messages will be logged



93
94
95
# File 'lib/action_mcp/logging/mixin.rb', line 93

def mcp_debug?
  mcp_logger.debug?
end

#mcp_emergency(message = nil, data: nil) { ... } ⇒ void

This method returns an undefined value.

Log an emergency message

Parameters:

  • message (String, nil) (defaults to: nil)

    The message (if no block given)

  • data (Object) (defaults to: nil)

    Additional structured data

Yields:

  • Block that returns the message (evaluated only if logging)



87
88
89
# File 'lib/action_mcp/logging/mixin.rb', line 87

def mcp_emergency(message = nil, data: nil, &block)
  mcp_logger.emergency(message, data: data, &block)
end

#mcp_emergency?Boolean

Check if emergency level is enabled

Returns:

  • (Boolean)

    true if emergency messages will be logged



136
137
138
# File 'lib/action_mcp/logging/mixin.rb', line 136

def mcp_emergency?
  mcp_logger.emergency?
end

#mcp_error(message = nil, data: nil) { ... } ⇒ void

This method returns an undefined value.

Log an error message

Parameters:

  • message (String, nil) (defaults to: nil)

    The message (if no block given)

  • data (Object) (defaults to: nil)

    Additional structured data

Yields:

  • Block that returns the message (evaluated only if logging)



60
61
62
# File 'lib/action_mcp/logging/mixin.rb', line 60

def mcp_error(message = nil, data: nil, &block)
  mcp_logger.error(message, data: data, &block)
end

#mcp_error?Boolean

Check if error level is enabled

Returns:

  • (Boolean)

    true if error messages will be logged



118
119
120
# File 'lib/action_mcp/logging/mixin.rb', line 118

def mcp_error?
  mcp_logger.error?
end

#mcp_info(message = nil, data: nil) { ... } ⇒ void

This method returns an undefined value.

Log an info message

Parameters:

  • message (String, nil) (defaults to: nil)

    The message (if no block given)

  • data (Object) (defaults to: nil)

    Additional structured data

Yields:

  • Block that returns the message (evaluated only if logging)



32
33
34
# File 'lib/action_mcp/logging/mixin.rb', line 32

def mcp_info(message = nil, data: nil, &block)
  mcp_logger.info(message, data: data, &block)
end

#mcp_info?Boolean

Check if info level is enabled

Returns:

  • (Boolean)

    true if info messages will be logged



99
100
101
# File 'lib/action_mcp/logging/mixin.rb', line 99

def mcp_info?
  mcp_logger.info?
end

#mcp_loggerActionMCP::Logging::Logger, ActionMCP::Logging::NullLogger

Get the MCP logger for this instance



11
12
13
14
15
16
# File 'lib/action_mcp/logging/mixin.rb', line 11

def mcp_logger
  @mcp_logger ||= ActionMCP::Logging.logger_for_context(
    name: logger_name,
    execution_context: execution_context
  )
end

#mcp_notice(message = nil, data: nil) { ... } ⇒ void

This method returns an undefined value.

Log a notice message

Parameters:

  • message (String, nil) (defaults to: nil)

    The message (if no block given)

  • data (Object) (defaults to: nil)

    Additional structured data

Yields:

  • Block that returns the message (evaluated only if logging)



41
42
43
# File 'lib/action_mcp/logging/mixin.rb', line 41

def mcp_notice(message = nil, data: nil, &block)
  mcp_logger.notice(message, data: data, &block)
end

#mcp_notice?Boolean

Check if notice level is enabled

Returns:

  • (Boolean)

    true if notice messages will be logged



105
106
107
# File 'lib/action_mcp/logging/mixin.rb', line 105

def mcp_notice?
  mcp_logger.notice?
end

#mcp_warning(message = nil, data: nil) { ... } ⇒ void Also known as: mcp_warn

This method returns an undefined value.

Log a warning message

Parameters:

  • message (String, nil) (defaults to: nil)

    The message (if no block given)

  • data (Object) (defaults to: nil)

    Additional structured data

Yields:

  • Block that returns the message (evaluated only if logging)



50
51
52
# File 'lib/action_mcp/logging/mixin.rb', line 50

def mcp_warning(message = nil, data: nil, &block)
  mcp_logger.warning(message, data: data, &block)
end

#mcp_warning?Boolean Also known as: mcp_warn?

Check if warning level is enabled

Returns:

  • (Boolean)

    true if warning messages will be logged



111
112
113
# File 'lib/action_mcp/logging/mixin.rb', line 111

def mcp_warning?
  mcp_logger.warning?
end