Module: RubynCode::Debug
- Defined in:
- lib/rubyn_code/debug.rb
Constant Summary collapse
- PASTEL =
Pastel.new
Class Attribute Summary collapse
-
.enabled ⇒ Object
readonly
Returns the value of attribute enabled.
-
.output ⇒ Object
writeonly
Sets the attribute output.
Class Method Summary collapse
- .agent(message) ⇒ Object
- .disable! ⇒ Object
- .enable! ⇒ Object
- .enabled? ⇒ Boolean
- .error(message) ⇒ Object
-
.llm(message) ⇒ Object
── Convenience methods ───────────────────────────────────────.
-
.log(tag, message, color: :dim) ⇒ Object
── Core logging ──────────────────────────────────────────────.
- .loop_tick(message) ⇒ Object
- .recovery(message) ⇒ Object
- .token(message) ⇒ Object
- .tool(message) ⇒ Object
- .warn(message) ⇒ Object
Class Attribute Details
.enabled ⇒ Object (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
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() log('agent', , 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
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() log('error', , color: :red) end |
.llm(message) ⇒ Object
── Convenience methods ───────────────────────────────────────
41 42 43 |
# File 'lib/rubyn_code/debug.rb', line 41 def llm() log('llm', , 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, , color: :dim) return unless enabled? = Time.now.strftime('%H:%M:%S.%L') prefix = "#{PASTEL.dim("[#{}]")} #{PASTEL.send(color, "[#{tag}]")}" @output.puts "#{prefix} #{}" end |
.loop_tick(message) ⇒ Object
53 54 55 |
# File 'lib/rubyn_code/debug.rb', line 53 def loop_tick() log('loop', , color: :green) end |
.recovery(message) ⇒ Object
57 58 59 |
# File 'lib/rubyn_code/debug.rb', line 57 def recovery() log('recovery', , color: :red) end |
.token(message) ⇒ Object
61 62 63 |
# File 'lib/rubyn_code/debug.rb', line 61 def token() log('token', , color: :blue) end |
.tool(message) ⇒ Object
45 46 47 |
# File 'lib/rubyn_code/debug.rb', line 45 def tool() log('tool', , color: :cyan) end |
.warn(message) ⇒ Object
65 66 67 |
# File 'lib/rubyn_code/debug.rb', line 65 def warn() log('warn', , color: :yellow) end |