houseabsolute / Devel-StackTrace

An object representing a stack trace
https://metacpan.org/release/Devel-StackTrace/
Other
7 stars 13 forks source link

Enhancement proposal: Allow user to format stacktrace #12

Open autarch opened 7 years ago

autarch commented 7 years ago

Migrated from rt.cpan.org #54611 (status was 'open')

Requestors:

Attachments:

From milu71@googlemail.com on 2010-02-15 02:37:28:

(As outlined by mail privately the other day:)

Currently, the user has limited control over the way the stacktrace is formatted for display. It would be nice to be able to have stacktraces in ANSI colors, for example. They stand out better in the logfile.

The modifications required to accomodate this new feature are relatively minor. See the attached patch (not the same as the one

autarch commented 7 years ago

From autarch@urth.org (@autarch) on 2010-02-15 03:04:56:

On Sun, 14 Feb 2010, Michael Ludwig via RT wrote:

(As outlined by mail privately the other day:)

Currently, the user has limited control over the way the stacktrace is formatted for display. It would be nice to be able to have stacktraces in ANSI colors, for example. They stand out better in the logfile.

The modifications required to accomodate this new feature are relatively minor. See the attached patch (not the same as the one

I think this would be better done as hooks to allow the use of subclasses as needed, rather than adding functionality to D::ST itself.

If you're using Exception::Class, you might also want to tweak that module to allow for a custom stacktrace subclass.

-dave

/============================================================ http://VegGuide.org http://blog.urth.org Your guide to all that's veg House Absolute(ly Pointless) ============================================================/

autarch commented 7 years ago

From milu71@googlemail.com on 2010-02-15 10:54:50:

Am So 14. Feb 2010, 22:04:56, autarch@urth.org schrieb:

The modifications required to accomodate this new feature are relatively minor. See the attached patch (not the same as the one

I think this would be better done as hooks to allow the use of subclasses as needed, rather than adding functionality to D::ST itself.

My patch does not add any functionality at all to D::ST. It just allows the user to pass in subroutine references as parameters, defaulting to the existing formatting implementation.

Plus, it resolves what you've marked as "hack" in the code, where StackFrame explicitly calls StackTrace's method, and it also gets rid of one redundant if statement preceding a for loop.

Maybe you could take another look at the patch? The documentation will be updated once you agree this enhancement makes sense.

If you're using Exception::Class, you might also want to tweak that module to allow for a custom stacktrace subclass.

I'm not using Exception::Class. Devel::StackTrace is just really fine in that it has almost zero dependencies.

Best,

Michael

autarch commented 7 years ago

From milu71@googlemail.com on 2010-02-15 10:59:20:

Am So 14. Feb 2010, 22:04:56, autarch@urth.org schrieb:

I think this would be better done as hooks to allow the use of subclasses as needed, rather than adding functionality to D::ST itself.

I considered subclassing, but the arrangement of D::ST as a pair of classes - Devel::StackTrace and Devel::StackTraceFrame - made parametrizing seem to me less intrusive and easier.

Michael

autarch commented 7 years ago

From milu71@googlemail.com on 2010-03-07 19:52:09:

Hi Dave,

Am So 14. Feb 2010, 22:04:56, autarch@urth.org schrieb:

I think this would be better done as hooks to allow the use of subclasses as needed, rather than adding functionality to D::ST itself.

Hi Dave,

are you still considering the issue or have you made up your mind about it? It would be good to let me know.

If you tend to decline the patch, are you considering releasing a new version of D::ST that provides hooks for formatting?

Please note that my patch does not add functionality to D::ST itself, it just allows for parameterizing the formatting code, leaving your formatting implementation as the default handler.

I think that's preferable to having to extend D::ST in order to modify how messages are formatted, and it exploits the great Perl feature of subroutines as data objects, but ultimately it might be a matter of taste, and some people just prefer inheritance, despite Perl's poor OO support built up around @ISA.

Best,

Michael

autarch commented 7 years ago

From autarch@urth.org (@autarch) on 2010-03-10 03:16:19:

On Sun, 7 Mar 2010, Michael Ludwig via RT wrote:

If you tend to decline the patch, are you considering releasing a new version of D::ST that provides hooks for formatting?

Like I said, I'd rather see a hooks to allow using a different Frame class in D::ST itself. Then you can easily write a subclass which formats however you like. That way, in the future, if someone else wants an unrelated feature which would otherwise need a hook, they can just write a subclass.

-dave

/============================================================ http://VegGuide.org http://blog.urth.org Your guide to all that's veg House Absolute(ly Pointless) ============================================================/

autarch commented 7 years ago

From milu71@gmx.de on 2010-03-10 12:59:02:

autarch@urth.org via RT schrieb am 09.03.2010 um 22:16:26 (-0500):

<URL: http://rt.cpan.org/Ticket/Display.html?id=54611 >

On Sun, 7 Mar 2010, Michael Ludwig via RT wrote:

If you tend to decline the patch, are you considering releasing a new version of D::ST that provides hooks for formatting?

Like I said, I'd rather see a hooks to allow using a different Frame class in D::ST itself. Then you can easily write a subclass which formats however you like. That way, in the future, if someone else wants an unrelated feature which would otherwise need a hook, they can just write a subclass.

Well, fair enough, it's your module. I think that way, it'll take a little more refactoring than going with callback parameters. I'm waiting for the release, then.

-- Michael Ludwig

autarch commented 7 years ago

From autarch@urth.org (@autarch) on 2010-03-10 17:33:42:

On Wed, 10 Mar 2010, Michael Ludwig via RT wrote:

Well, fair enough, it's your module. I think that way, it'll take a little more refactoring than going with callback parameters. I'm waiting for the release, then.

You might be waiting a while. I think this is your itch, not mine.

-dave

/============================================================ http://VegGuide.org http://blog.urth.org Your guide to all that's veg House Absolute(ly Pointless) ============================================================/

autarch commented 7 years ago

From milu71@gmx.de on 2010-03-10 20:31:15:

autarch@urth.org via RT schrieb am 10.03.2010 um 12:33:43 (-0500):

<URL: https://rt.cpan.org/Ticket/Display.html?id=54611 >

On Wed, 10 Mar 2010, Michael Ludwig via RT wrote:

Well, fair enough, it's your module. I think that way, it'll take a little more refactoring than going with callback parameters. I'm waiting for the release, then.

You might be waiting a while. I think this is your itch, not mine.

Cool! Maybe a fork will do then :-)

-- Michael Ludwig

autarch commented 7 years ago

From autarch@urth.org (@autarch) on 2010-03-10 21:55:50:

On Wed, 10 Mar 2010, Michael Ludwig via RT wrote:

  Queue: Devel-StackTrace

Ticket <URL: http://rt.cpan.org/Ticket/Display.html?id=54611 >

autarch@urth.org via RT schrieb am 10.03.2010 um 12:33:43 (-0500):

<URL: https://rt.cpan.org/Ticket/Display.html?id=54611 >

On Wed, 10 Mar 2010, Michael Ludwig via RT wrote:

Well, fair enough, it's your module. I think that way, it'll take a little more refactoring than going with callback parameters. I'm waiting for the release, then.

You might be waiting a while. I think this is your itch, not mine.

Cool! Maybe a fork will do then :-)

A fork isn't necessary. Just give me a patch to add subclassibility and I'll apply it and release.

-dave

/============================================================ http://VegGuide.org http://blog.urth.org Your guide to all that's veg House Absolute(ly Pointless) ============================================================/

autarch commented 7 years ago

From milu71@gmx.de on 2010-03-10 22:57:31:

autarch@urth.org via RT schrieb am 10.03.2010 um 16:55:51 (-0500):

<URL: http://rt.cpan.org/Ticket/Display.html?id=54611 >

On Wed, 10 Mar 2010, Michael Ludwig via RT wrote:

Cool! Maybe a fork will do then :-)

A fork isn't necessary. Just give me a patch to add subclassibility and I'll apply it and release.

Okay, that's a different song. I'll see what I can come up - later. Won't have time to look at this during the next couple of days.

-- Michael Ludwig