ReqLLM.Debug (ReqLLM v1.0.0)

View Source

Centralized debug logging for ReqLLM development and troubleshooting.

Provides helpers for emitting debug messages when the REQ_LLM_DEBUG environment variable is set to "1", "true", "yes", or "on".

Usage

import ReqLLM.Debug, only: [dbug: 1, dbug: 2]

dbug("Simple message", component: :fixtures)
dbug(fn -> "Expensive #{calculation()}" end, component: :stream_server)

All debug logs are tagged with req_llm: true metadata for filtering.

Summary

Functions

Macro alias for log/2 that can be imported for cleaner syntax.

Returns true if debug logging is enabled.

Emit an info-level log message if debugging is enabled.

Emit a debug-level log message if debugging is enabled.

Functions

dbug(message_or_fun, metadata \\ [])

(macro)

Macro alias for log/2 that can be imported for cleaner syntax.

Examples

import ReqLLM.Debug, only: [dbug: 2]
dbug("Message", component: :stream_server)

enabled?()

@spec enabled?() :: boolean()

Returns true if debug logging is enabled.

Checks Application config first, then falls back to environment variable.

info(message_or_fun, metadata \\ [])

@spec info(
  String.t() | (-> String.t()),
  keyword()
) :: :ok

Emit an info-level log message if debugging is enabled.

Accepts either a string or a zero-arity function for lazy evaluation. Additional metadata can be provided via keyword list.

log(message_or_fun, metadata \\ [])

@spec log(
  String.t() | (-> String.t()),
  keyword()
) :: :ok

Emit a debug-level log message if debugging is enabled.

Accepts either a string or a zero-arity function for lazy evaluation. Additional metadata can be provided via keyword list.

Examples

dbg("Starting operation")
dbg(fn -> "Result: #{expensive_operation()}" end, component: :fixtures)