# `SuperCache.Log`
[🔗](https://github.com/ohhi-vn/super_cache/blob/main/lib/debug_log.ex#L17)

Conditional logging for SuperCache.

Debug output is suppressed by default.  Enable in two ways:

**Compile-time** (evaluated at compile time, zero overhead when disabled):

    # config/config.exs
    config :super_cache, debug_log: true

**Runtime** (can be toggled while the system is running):

    SuperCache.Log.enable(true)

All internal logging calls are routed through this module so that when
debug is disabled, no message strings are built and no function calls
are made — the macro expands to `:ok`.

## Examples

    require SuperCache.Log

    # Lazy evaluation — only called when debug is enabled
    SuperCache.Log.debug(fn -> "expensive: #{inspect(large_data)}" end)

    # Direct string or iodata
    SuperCache.Log.debug("simple message")
    SuperCache.Log.info("operation completed")

# `debug`
*macro* 

Emit a debug log if debug logging is enabled.

Accepts a string, iodata, or a zero-arity anonymous function (lazy
evaluation).  When disabled, this macro expands to `:ok` so no work
is performed.

## Examples

    require SuperCache.Log

    SuperCache.Log.debug("starting operation")
    SuperCache.Log.debug(fn -> "data: #{inspect(large_struct)}" end)

# `enable`

```elixir
@spec enable(boolean()) :: :ok
```

Enable or disable debug logging at runtime.

This overrides the compile-time setting.  Pass `true` to enable, `false`
to disable.

## Examples

    SuperCache.Log.enable(true)
    SuperCache.Log.enable(false)

# `enabled?`

```elixir
@spec enabled?() :: boolean()
```

Returns whether debug logging is currently enabled.

Checks the runtime toggle first; if not set, falls back to the
compile-time configuration.

# `error`
*macro* 

Emit an error log.

Always logs — not gated by the debug toggle.

## Examples

    SuperCache.Log.error("3PC commit failed: timeout")

# `info`
*macro* 

Emit an info log.

Unlike `debug/1`, this always logs (info is not gated by the debug
toggle), but it still accepts lazy functions for consistency.

## Examples

    SuperCache.Log.info("cache started with 8 partitions")

# `warning`
*macro* 

Emit a warning log.

Always logs — not gated by the debug toggle.

## Examples

    SuperCache.Log.warning("node not reachable, will retry")

---

*Consult [api-reference.md](api-reference.md) for complete listing*
