NAME
Log::Any::Proxy::WithStackTrace - Log::Any proxy to upgrade string errors to objects with stack traces
VERSION
version 1.712
SYNOPSIS
use Log::Any qw( $log, proxy_class => 'WithStackTrace' );
# Some adapter that knows how to handle both structured data,
# and log messages which are actually objects with a
# "stack_trace" method:
#
Log::Any::Adapter->set($adapter);
$log->error("Help!"); # stack trace gets automatically added
DESCRIPTION
Some log adapters, like Log::Any::Adapter::Sentry::Raven, are able to take advantage of being passed message objects that contain a stack trace. However if a stack trace is not available, and fallback logic is used to generate one, the resulting trace can be confusing if it begins relative to where the log adapter was called, and not relative to where the logging method was originally called.
With this proxy in place, if any logging method is called with a message that is a non-reference scalar, that message will be upgraded into a Log::Any::MessageWithStackTrace
object with a stack_trace
method, and that method will return a trace relative to where the logging method was called. A string overload is provided on the object to return the original message.
Important: This proxy should be used with a Log::Any::Adapter that is configured to handle structured data. Otherwise the object created here will just get stringified before it can be used to access the stack trace.
METHODS
maybe_upgrade_with_stack_trace
This is an internal use method that will convert a non-reference scalar message into a Log::Any::MessageWithStackTrace
object with a stack_trace
method. A string overload is provided to return the original message.
AUTHORS
Jonathan Swartz <swartz@pobox.com>
David Golden <dagolden@cpan.org>
Doug Bell <preaction@cpan.org>
Daniel Pittman <daniel@rimspace.net>
Stephen Thirlwall <sdt@cpan.org>
COPYRIGHT AND LICENSE
This software is copyright (c) 2017 by Jonathan Swartz, David Golden, and Doug Bell.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.