{
    "mode": "perldoc",
    "parameter": "Log::Any::Proxy::WithStackTrace",
    "section": "",
    "url": "https://www.chedong.com/phpMan.php/perldoc/Log%3A%3AAny%3A%3AProxy%3A%3AWithStackTrace/json",
    "generated": "2026-10-09T16:57:55Z",
    "synopsis": "use Log::Any qw( $log, proxyclass => 'WithStackTrace' );\n# Allow stack trace call stack arguments to be logged:\nuse Log::Any qw( $log, proxyclass => 'WithStackTrace',\nproxyshowstacktraceargs => 1 );\n# Configure some adapter that knows how to:\n#  1) handle structured data, and\n#  2) handle message objects which have a \"stacktrace\" method:\nLog::Any::Adapter->set($adapter);\n$log->error(\"Help!\");   # stack trace gets automatically added,\n# starting from this line of code",
    "sections": {
        "NAME": {
            "content": "Log::Any::Proxy::WithStackTrace - Log::Any proxy to upgrade string errors to objects with stack\ntraces\n",
            "subsections": []
        },
        "VERSION": {
            "content": "version 1.717\n",
            "subsections": []
        },
        "SYNOPSIS": {
            "content": "use Log::Any qw( $log, proxyclass => 'WithStackTrace' );\n\n# Allow stack trace call stack arguments to be logged:\nuse Log::Any qw( $log, proxyclass => 'WithStackTrace',\nproxyshowstacktraceargs => 1 );\n\n# Configure some adapter that knows how to:\n#  1) handle structured data, and\n#  2) handle message objects which have a \"stacktrace\" method:\nLog::Any::Adapter->set($adapter);\n\n$log->error(\"Help!\");   # stack trace gets automatically added,\n# starting from this line of code\n",
            "subsections": []
        },
        "DESCRIPTION": {
            "content": "Some log adapters, like Log::Any::Adapter::Sentry::Raven, are able to take advantage of being\npassed message objects that contain a stack trace. However if a stack trace is not available,\nand fallback logic is used to generate one, the resulting trace can be confusing if it begins\nrelative to where the log adapter was called, and not relative to where the logging method was\noriginally called.\n\nWith this proxy in place, if any logging method is called with a log message that is a\nnon-reference scalar (i.e. a string), that log message will be upgraded into a\n\"Log::Any::MessageWithStackTrace\" object with a \"stacktrace\" method, and that method will\nreturn a trace relative to where the logging method was called. A string overload is provided on\nthe object to return the original log message.\n\nAdditionally, any call stack arguments in the stack trace will be deleted before logging, to\navoid accidentally logging sensitive data. This happens both for message objects that were\nauto-generated from string messages, as well as for message objects that were passed in directly\n(if they appear to have a stack trace method). This default argument scrubbing behavior can be\nturned off by specifying a true value for the \"proxyshowstacktraceargs\" import flag.\n\nImportant: This proxy should be used with a Log::Any::Adapter that is configured to handle\nstructured data. Otherwise the object created here will just get stringified before it can be\nused to access the stack trace.\n",
            "subsections": []
        },
        "METHODS": {
            "content": "maybeupgradewithstacktrace\n@args = $self->maybeupgradewithstacktrace(@args);\n\nThis is an internal-use method that will convert a non-reference scalar message into a\n\"Log::Any::MessageWithStackTrace\" object with a \"stacktrace\" method. A string overload is\nprovided to return the original message.\n\nStack trace args are scrubbed out in case they contain sensitive data, unless the\n\"proxyshowstacktraceargs\" option has been set.\n\nmaybedeletestacktraceargs\n$self->maybedeletestacktraceargs($arg);\n\nThis is an internal-use method that, given a single argument that is a reference, tries to\nfigure out whether the argument is an object with a stack trace, and if so tries to delete any\nstack trace args.\n\nThe logic is based on Devel::StackTrace::Extract.\n\nIt specifically looks for objects with a \"stacktrace\" method (which should catch anything that\ndoes StackTrace::Auto, including anything that does Throwable::Error), or a \"trace\" method (used\nby Exception::Class and Moose::Exception and friends).\n\nIt specifically ignores Mojo::Exception objects, because their stack traces don't contain any\ncall stack args.\n\ndeleteargsfromstacktrace($trace)\n$self->deleteargsfromstacktrace($trace)\n\nTo scrub potentially sensitive data from \"Devel::StackTrace\" arguments, this method deletes\narguments from all of the \"Devel::StackTrace::Frame\" in the trace.\n",
            "subsections": []
        },
        "AUTHORS": {
            "content": "*   Jonathan Swartz <swartz@pobox.com>\n\n*   David Golden <dagolden@cpan.org>\n\n*   Doug Bell <preaction@cpan.org>\n\n*   Daniel Pittman <daniel@rimspace.net>\n\n*   Stephen Thirlwall <sdt@cpan.org>\n",
            "subsections": []
        },
        "COPYRIGHT AND LICENSE": {
            "content": "This software is copyright (c) 2017 by Jonathan Swartz, David Golden, and Doug Bell.\n\nThis is free software; you can redistribute it and/or modify it under the same terms as the Perl\n5 programming language system itself.\n",
            "subsections": []
        }
    },
    "summary": "Log::Any::Proxy::WithStackTrace - Log::Any proxy to upgrade string errors to objects with stack traces",
    "flags": [],
    "examples": [],
    "see_also": []
}