Module: RubynCode::Debug

Defined in:
lib/rubyn_code/debug.rb

Constant Summary collapse

PASTEL =
Pastel.new

Class Attribute Summary collapse

Class Method Summary collapse

Class Attribute Details

.enabledObject (readonly)

Returns the value of attribute enabled.



13
14
15
# File 'lib/rubyn_code/debug.rb', line 13

def enabled
  @enabled
end

.output=(value) ⇒ Object (writeonly)

Sets the attribute output

Parameters:

  • value

    the value to set the attribute output to.



27
28
29
# File 'lib/rubyn_code/debug.rb', line 27

def output=(value)
  @output = value
end

Class Method Details

.agent(message) ⇒ Object



49
50
51
# File 'lib/rubyn_code/debug.rb', line 49

def agent(message)
  log('agent', message, color: :yellow)
end

.disable!Object



19
20
21
# File 'lib/rubyn_code/debug.rb', line 19

def disable!
  @enabled = false
end

.enable!Object



15
16
17
# File 'lib/rubyn_code/debug.rb', line 15

def enable!
  @enabled = true
end

.enabled?Boolean

Returns:

  • (Boolean)


23
24
25
# File 'lib/rubyn_code/debug.rb', line 23

def enabled?
  @enabled || ENV.fetch('RUBYN_DEBUG', nil)
end

.error(message) ⇒ Object



69
70
71
# File 'lib/rubyn_code/debug.rb', line 69

def error(message)
  log('error', message, color: :red)
end

.llm(message) ⇒ Object

── Convenience methods ───────────────────────────────────────



41
42
43
# File 'lib/rubyn_code/debug.rb', line 41

def llm(message)
  log('llm', message, color: :magenta)
end

.log(tag, message, color: :dim) ⇒ Object

── Core logging ──────────────────────────────────────────────



31
32
33
34
35
36
37
# File 'lib/rubyn_code/debug.rb', line 31

def log(tag, message, color: :dim)
  return unless enabled?

  timestamp = Time.now.strftime('%H:%M:%S.%L')
  prefix = "#{PASTEL.dim("[#{timestamp}]")} #{PASTEL.send(color, "[#{tag}]")}"
  @output.puts "#{prefix} #{message}"
end

.loop_tick(message) ⇒ Object



53
54
55
# File 'lib/rubyn_code/debug.rb', line 53

def loop_tick(message)
  log('loop', message, color: :green)
end

.recovery(message) ⇒ Object



57
58
59
# File 'lib/rubyn_code/debug.rb', line 57

def recovery(message)
  log('recovery', message, color: :red)
end

.token(message) ⇒ Object



61
62
63
# File 'lib/rubyn_code/debug.rb', line 61

def token(message)
  log('token', message, color: :blue)
end

.tool(message) ⇒ Object



45
46
47
# File 'lib/rubyn_code/debug.rb', line 45

def tool(message)
  log('tool', message, color: :cyan)
end

.warn(message) ⇒ Object



65
66
67
# File 'lib/rubyn_code/debug.rb', line 65

def warn(message)
  log('warn', message, color: :yellow)
end