# `Snakepit.Logger`
[🔗](https://github.com/nshkrdotcom/snakepit/blob/v0.13.0/lib/snakepit/logger.ex#L1)

Centralized, silent-by-default logging for Snakepit.

## Configuration

    # Silent (default) - only errors
    config :snakepit, log_level: :error

    # Warnings and errors
    config :snakepit, log_level: :warning

    # Verbose - info, warnings, errors
    config :snakepit, log_level: :info

    # Debug - everything
    config :snakepit, log_level: :debug

    # Completely silent (not even errors)
    config :snakepit, log_level: :none

## Categories

Enable specific categories for targeted debugging:

    config :snakepit, log_categories: [:lifecycle, :grpc]

## Process-Level Isolation (for Testing)

Log levels can be set per-process to avoid race conditions in async tests:

    # Set log level for current process only
    Snakepit.Logger.set_process_level(:debug)

    # Execute with temporary log level
    Snakepit.Logger.with_level(:warning, fn ->
      # ... code that should log at warning level
    end)

    # Clear process-level override
    Snakepit.Logger.clear_process_level()

The resolution order is:
1. Process-level override (via `set_process_level/1`)
2. Elixir Logger process level (via `Logger.put_process_level/2`)
3. Application config (via `config :snakepit, log_level: ...`)

# `category`

```elixir
@type category() ::
  :lifecycle
  | :pool
  | :grpc
  | :bridge
  | :worker
  | :startup
  | :shutdown
  | :telemetry
  | :general
```

# `level`

```elixir
@type level() :: :debug | :info | :warning | :error | :none
```

# `clear_process_level`

```elixir
@spec clear_process_level() :: :ok
```

Clear the process-level log level override.

After calling this, the process will use the global Application config.

# `debug`

# `debug`

# `debug`

Log at debug level if configured log level allows it.

# `error`

# `error`

# `error`

Log at error level if configured log level allows it.

# `get_process_level`

```elixir
@spec get_process_level() :: level()
```

Get the effective log level for the current process.

Returns the log level in priority order:
1. Process-level override (set via `set_process_level/1`)
2. Elixir Logger process level
3. Application config

# `info`

# `info`

# `info`

Log at info level if configured log level allows it.

# `set_process_level`

```elixir
@spec set_process_level(level()) :: :ok
```

Set the log level for the current process only.

This is useful for test isolation - each test process can have its own
log level without affecting other concurrent tests.

## Examples

    Snakepit.Logger.set_process_level(:debug)
    # All logging in this process now uses :debug level

    Snakepit.Logger.set_process_level(:none)
    # All logging in this process is now suppressed

# `should_log?`

Check if logging at the given level is enabled.

# `should_log?`

Check if logging at the given level/category is enabled.

# `warning`

# `warning`

# `warning`

Log at warning level if configured log level allows it.

# `with_level`

```elixir
@spec with_level(level(), (-&gt; result)) :: result when result: term()
```

Execute a function with a temporary log level for the current process.

The previous log level is restored after the function completes,
even if it raises an exception.

## Examples

    Snakepit.Logger.with_level(:debug, fn ->
      # Debug logs are enabled here
      Snakepit.Logger.debug(:pool, "detailed info")
    end)
    # Previous log level is restored

---

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