[pve-devel] [PATCH http-server v2 1/5] add debug print helper
Thomas Lamprecht
t.lamprecht at proxmox.com
Mon Dec 7 11:11:17 CET 2020
On 04.12.20 18:56, Stoiko Ivanov wrote:
> Suggested-by: Thomas Lamprecht <t.lamprecht at proxmox.com>
> Signed-off-by: Stoiko Ivanov <s.ivanov at proxmox.com>
> ---
> PVE/APIServer/AnyEvent.pm | 10 ++++++++++
> 1 file changed, 10 insertions(+)
>
> diff --git a/PVE/APIServer/AnyEvent.pm b/PVE/APIServer/AnyEvent.pm
> index c55da7f..7916bdd 100644
> --- a/PVE/APIServer/AnyEvent.pm
> +++ b/PVE/APIServer/AnyEvent.pm
> @@ -66,6 +66,16 @@ my $split_abs_uri = sub {
> return wantarray ? ($rel_uri, $format) : $rel_uri;
> };
>
> +sub dprint {
> + my ($self, $message) = @_;
> +
> + return if !$self->{debug};
> +
> + my ($pkg, $pkgfile, $line, $sub) = caller(1);
> + $sub =~ s/^.+::([^:]+)$/\1/;
Could be a bit simpler, avoiding capturing group and back reference:
$sub =~ s/^(?:.+::)+//;
(note did not actually test it)
> + print "worker[$$]: $pkg +$line: $sub: $message\n";
> +}
> +
> sub log_request {
> my ($self, $reqstate) = @_;
>
>
please merge 5/5 into this one, makes no sense to have that split and the
use part ordered last.
More information about the pve-devel
mailing list