NAME

Claude::Agent::Logger - Configurable logging for Claude Agent SDK

SYNOPSIS

# In your application - configure logging via environment:
# CLAUDE_AGENT_DEBUG=1 perl myapp.pl           # debug level to stderr
# CLAUDE_AGENT_LOG_LEVEL=trace perl myapp.pl   # trace level to stderr
# CLAUDE_AGENT_LOG_OUTPUT=/tmp/app.log perl myapp.pl  # log to file

# Or configure your own adapter (takes precedence):
use Log::Any::Adapter ('Screen', colored => 1);
use Claude::Agent qw(query);

# In library code (single import does both setup and $log export):
use Claude::Agent::Logger '$log';
$log->debug("Starting query");
$log->trace("Verbose details: %s", $data);

DESCRIPTION

This module configures Log::Any with sensible defaults for the Claude Agent SDK. It provides:

  • Default adapter (Stderr) so logs aren't lost

  • Environment variable configuration

  • Backward compatibility with CLAUDE_AGENT_DEBUG

  • User can override with their own Log::Any::Adapter

ENVIRONMENT VARIABLES

CLAUDE_AGENT_LOG_LEVEL

Set the minimum log level. Values: trace, debug, info, notice, warning, error, critical, alert, emergency. Default: warning

CLAUDE_AGENT_LOG_OUTPUT

Set the output destination. Values: stderr, stdout, or a file path. Default: stderr

CLAUDE_AGENT_DEBUG

Backward compatibility. Set to 1 for debug level, 2 for trace level. CLAUDE_AGENT_LOG_LEVEL takes precedence if both are set.

USER CONFIGURATION

Users can configure their own Log::Any adapter which takes precedence over environment variables:

use Log::Any::Adapter ('Screen', colored => 1);
use Log::Any::Adapter ('File', '/var/log/myapp.log');
use Log::Any::Adapter ('Log4perl');

FUNCTIONS

get_logger

my $log = Claude::Agent::Logger::get_logger();
my $log = Claude::Agent::Logger::get_logger('My::Category');

Returns a Log::Any logger instance. Optionally pass a category name.

AUTHOR

LNATION, <email at lnation.org>

LICENSE

This software is Copyright (c) 2026 by LNATION.

This is free software, licensed under The Artistic License 2.0 (GPL Compatible).