Class: ActionMCP::Logging::Logger

Inherits:
Object
  • Object
show all
Defined in:
lib/action_mcp/logging/logger.rb

Overview

MCP Logger that sends notifications/message to the MCP client

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name: nil, session:, state:) ⇒ Logger

Initialize a new MCP logger

Parameters:



13
14
15
16
17
# File 'lib/action_mcp/logging/logger.rb', line 13

def initialize(name: nil, session:, state:)
  @name = name
  @session = session
  @state = state
end

Instance Attribute Details

#nameObject (readonly)

Returns the value of attribute name.



7
8
9
# File 'lib/action_mcp/logging/logger.rb', line 7

def name
  @name
end

#sessionObject (readonly)

Returns the value of attribute session.



7
8
9
# File 'lib/action_mcp/logging/logger.rb', line 7

def session
  @session
end

#stateObject (readonly)

Returns the value of attribute state.



7
8
9
# File 'lib/action_mcp/logging/logger.rb', line 7

def state
  @state
end

Instance Method Details

#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)



79
80
81
# File 'lib/action_mcp/logging/logger.rb', line 79

def alert(message = nil, data: nil, &block)
  log(:alert, message, data: data, &block)
end

#alert?Boolean

Check if alert level is enabled

Returns:

  • (Boolean)

    true if alert messages will be logged



131
132
133
# File 'lib/action_mcp/logging/logger.rb', line 131

def alert?
  state.should_log?(:alert)
end

#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)



70
71
72
# File 'lib/action_mcp/logging/logger.rb', line 70

def critical(message = nil, data: nil, &block)
  log(:critical, message, data: data, &block)
end

#critical?Boolean

Check if critical level is enabled

Returns:

  • (Boolean)

    true if critical messages will be logged



125
126
127
# File 'lib/action_mcp/logging/logger.rb', line 125

def critical?
  state.should_log?(:critical)
end

#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)



24
25
26
# File 'lib/action_mcp/logging/logger.rb', line 24

def debug(message = nil, data: nil, &block)
  log(:debug, message, data: data, &block)
end

#debug?Boolean

Check if debug level is enabled

Returns:

  • (Boolean)

    true if debug messages will be logged



94
95
96
# File 'lib/action_mcp/logging/logger.rb', line 94

def debug?
  state.should_log?(:debug)
end

#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)



88
89
90
# File 'lib/action_mcp/logging/logger.rb', line 88

def emergency(message = nil, data: nil, &block)
  log(:emergency, message, data: data, &block)
end

#emergency?Boolean

Check if emergency level is enabled

Returns:

  • (Boolean)

    true if emergency messages will be logged



137
138
139
# File 'lib/action_mcp/logging/logger.rb', line 137

def emergency?
  state.should_log?(:emergency)
end

#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)



61
62
63
# File 'lib/action_mcp/logging/logger.rb', line 61

def error(message = nil, data: nil, &block)
  log(:error, message, data: data, &block)
end

#error?Boolean

Check if error level is enabled

Returns:

  • (Boolean)

    true if error messages will be logged



119
120
121
# File 'lib/action_mcp/logging/logger.rb', line 119

def error?
  state.should_log?(:error)
end

#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)



33
34
35
# File 'lib/action_mcp/logging/logger.rb', line 33

def info(message = nil, data: nil, &block)
  log(:info, message, data: data, &block)
end

#info?Boolean

Check if info level is enabled

Returns:

  • (Boolean)

    true if info messages will be logged



100
101
102
# File 'lib/action_mcp/logging/logger.rb', line 100

def info?
  state.should_log?(:info)
end

#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)



42
43
44
# File 'lib/action_mcp/logging/logger.rb', line 42

def notice(message = nil, data: nil, &block)
  log(:notice, message, data: data, &block)
end

#notice?Boolean

Check if notice level is enabled

Returns:

  • (Boolean)

    true if notice messages will be logged



106
107
108
# File 'lib/action_mcp/logging/logger.rb', line 106

def notice?
  state.should_log?(:notice)
end

#warning(message = nil, data: nil) { ... } ⇒ void Also known as: 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)



51
52
53
# File 'lib/action_mcp/logging/logger.rb', line 51

def warning(message = nil, data: nil, &block)
  log(:warning, message, data: data, &block)
end

#warning?Boolean Also known as: warn?

Check if warning level is enabled

Returns:

  • (Boolean)

    true if warning messages will be logged



112
113
114
# File 'lib/action_mcp/logging/logger.rb', line 112

def warning?
  state.should_log?(:warning)
end