Class: FastMcp::Logger

Inherits:
Logger
  • Object
show all
Defined in:
lib/mcp/logger.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(transport: :stdio) ⇒ Logger

Returns a new instance of Logger.



6
7
8
9
10
11
12
# File 'lib/mcp/logger.rb', line 6

def initialize(transport: :stdio)
  @client_initialized = false
  @transport = transport

  # we don't want to log to stdout if we're using the stdio transport
  super($stdout) unless stdio_transport?
end

Instance Attribute Details

#client_initializedObject Also known as: client_initialized?

Returns the value of attribute client_initialized.



14
15
16
# File 'lib/mcp/logger.rb', line 14

def client_initialized
  @client_initialized
end

#transportObject

Returns the value of attribute transport.



14
15
16
# File 'lib/mcp/logger.rb', line 14

def transport
  @transport
end

Instance Method Details

#add(severity, message = nil, progname = nil, &block) ⇒ Object



21
22
23
24
25
26
# File 'lib/mcp/logger.rb', line 21

def add(severity, message = nil, progname = nil, &block)
  return if stdio_transport? # we don't want to log to stdout if we're using the stdio transport

  # TODO: implement logging as the specification requires
  super
end

#rack_transport?Boolean

Returns:

  • (Boolean)


28
29
30
# File 'lib/mcp/logger.rb', line 28

def rack_transport?
  transport == :rack
end

#stdio_transport?Boolean

Returns:

  • (Boolean)


17
18
19
# File 'lib/mcp/logger.rb', line 17

def stdio_transport?
  transport == :stdio
end