NAME
Log::Any::Adapter::Abstraction - Log::Any adapter backed by Log::Abstraction
VERSION
0.33
SYNOPSIS
use Log::Any::Adapter;
use Log::Abstraction;
# Option A: pass a pre-built Log::Abstraction instance
my $logger = Log::Abstraction->new(logger => \@messages, level => 'debug');
Log::Any::Adapter->set('Abstraction', instance => $logger);
# Option B: let the adapter create a Log::Abstraction for you
Log::Any::Adapter->set('Abstraction', level => 'debug', logger => \@messages);
# Any module that uses Log::Any will now route through Log::Abstraction
use Log::Any '$log';
$log->info('Hello world');
DESCRIPTION
Log::Any::Adapter::Abstraction is a Log::Any adapter that routes messages from any module using Log::Any through a Log::Abstraction backend. Configure a single Log::Abstraction instance (with file, syslog, email, array, or code-ref backends) and all Log::Any-using CPAN modules automatically send their output there.
Level mapping
Log::Any has nine severity levels; Log::Abstraction has six. The mapping is:
Log::Any level Log::Abstraction method
--------------- -----------------------
trace trace
debug debug
info info
notice notice
warning warn
error error
critical error
alert error
emergency error
critical, alert, and emergency all route to error() because Log::Abstraction follows the syslog six-level model.
METHODS
init
Called automatically by Log::Any::Adapter::Base::new(). Initialises the internal Log::Abstraction backend.
Arguments (passed as key=>value pairs to Log::Any::Adapter->set)
instanceAn existing
Log::Abstractionobject. When supplied, the adapter wraps it directly without creating a new instance.Any
Log::Abstraction->new()argumentlogger,level,file,fd,array,format,ctx,script_name,verbose. Used to build a freshLog::Abstractioninstance wheninstanceis not supplied.
Example
Log::Any::Adapter->set('Abstraction',
level => 'debug',
format => 'json',
file => '/var/log/myapp.log',
);
API Specification
Input
{
instance => { type => OBJECT, isa => 'Log::Abstraction', optional => 1 },
logger => { optional => 1 },
level => { type => SCALAR, optional => 1 },
file => { type => SCALAR, optional => 1 },
fd => { optional => 1 },
array => { type => ARRAYREF, optional => 1 },
format => { type => SCALAR, optional => 1 },
ctx => { optional => 1 },
script_name => { type => SCALAR, optional => 1 },
verbose => { type => BOOLEAN, optional => 1 },
}
Output
{ type => 'object', class => 'Log::Any::Adapter::Abstraction' }
MESSAGES
Error Meaning / Action
---------------------------------------- -----------------------------------------
(any Log::Abstraction croak) The supplied constructor args are invalid.
See Log::Abstraction for detail.
LIMITATIONS
- Nine-to-six level collapse
-
Log::Any has nine severity levels; Log::Abstraction has six.
critical,alert, andemergencyall map toerror(). Applications that rely on distinguishing these three levels in downstream Log::Abstraction backends will lose that distinction. - No structured field support
-
Log::Any's
log_fields()mechanism for structured fields is not forwarded to Log::Abstraction. Only the final formatted string is dispatched; callers that need structured output should use the Log::Abstraction CODE-ref backend and access the formatted string via themessagekey. - Log::Any as optional, not required
-
This adapter requires Log::Any at runtime, but Log::Any is listed as a
recommendsdependency rather thanrequires. CPAN clients that do not install recommended modules will allow this adapter to be installed but not loaded. Install Log::Any explicitly if you intend to use this adapter.
AUTHOR
Nigel Horne njh@nigelhorne.com
SEE ALSO
Log::Abstraction, Log::Any, Log::Any::Adapter
FORMAL SPECIFICATION
init ┌─ AdapterState ────────────────────────────────────────────── │ _logger : Log::Abstraction └─────────────────────────────────────────────────────────────
┌─ Init ──────────────────────────────────────────────────────
│ args? : { instance? : Log::Abstraction | logger_args }
│ result! : AdapterState
├─────────────────────────────────────────────────────────────
│ args?.instance ≠ ∅ ∧ isa(args?.instance, Log::Abstraction)
│ ⟹ result!._logger = args?.instance
│ args?.instance = ∅
│ ⟹ result!._logger = Log::Abstraction::new(logger_args)
└─────────────────────────────────────────────────────────────
COPYRIGHT AND LICENSE
Copyright (C) 2026 Nigel Horne
Usage is subject to the GPL2 licence terms. If you use it, please let me know.