From 97a15832399334e4d4835e48e28fc63695b94db7 Mon Sep 17 00:00:00 2001 From: espie Date: Sun, 29 Sep 2019 10:58:10 +0000 Subject: [PATCH] explain the handlers better also add a hook for tweaking Data::Dumper parameters --- infrastructure/lib/OpenBSD/Trace.pm | 27 ++++++++++++++++++++------- 1 file changed, 20 insertions(+), 7 deletions(-) diff --git a/infrastructure/lib/OpenBSD/Trace.pm b/infrastructure/lib/OpenBSD/Trace.pm index f324bd71c8a..412c2807edb 100644 --- a/infrastructure/lib/OpenBSD/Trace.pm +++ b/infrastructure/lib/OpenBSD/Trace.pm @@ -1,5 +1,5 @@ # ex:ts=8 sw=4: -# $OpenBSD: Trace.pm,v 1.1 2019/09/29 10:51:26 espie Exp $ +# $OpenBSD: Trace.pm,v 1.2 2019/09/29 10:58:10 espie Exp $ # # Copyright (c) 2015-2019 Marc Espie # @@ -27,6 +27,16 @@ package OpenBSD::Trace; my $forbidden = qr{[^[:print:]\s]}; +sub dumper +{ + my $self = shift; + + require Data::Dumper; + return Data::Dumper->new(@_)-> + Indent(0)->Maxdepth(1)->Quotekeys(0)->Sortkeys(1)-> + Deparse(1); +} + sub dump_param { my ($self, $arg, $full) = @_; @@ -40,10 +50,7 @@ sub dump_param } } if ($full) { - require Data::Dumper; - my $msg = Data::Dumper->new([$arg])-> - Indent(0)->Maxdepth(1)->Quotekeys(0)->Sortkeys(1)-> - Deparse(1)-> Dump; + my $msg = $self->dumper([$arg])->Dump; $msg =~ s/^\$VAR1 = //; $msg =~ s/\;$//; @@ -214,11 +221,17 @@ the stack dumping message is built using C<$self-Estack_dump($full)> =item * -the __WARN__ handler calls C<$self-Edo_warn($msg)> +the Data::Dumper object with options is built using C<$self-Edumper(@_)> =item * -the __DIE__ handler calls C<$self-Edo_die($msg)> +the C<$SIG{__WARN__}> handler calls C<$self-Edo_warn($msg)> after doing a +C + +=item * + +the C<$SIG{__DIE__}> handler calls C<$self-Edo_die($msg)> after doing a +C =item *