mirror of
https://github.com/percona/percona-toolkit.git
synced 2025-09-09 07:30:02 +00:00
Make pqd --output json have flags to enable sorted keys and prettyfied JSON
This commit is contained in:
@@ -7977,7 +7977,7 @@ sub _d {
|
||||
{
|
||||
package JSONReportFormatter;
|
||||
use Mo;
|
||||
use JSON;
|
||||
use JSON ();
|
||||
|
||||
use List::Util qw(sum);
|
||||
|
||||
@@ -7985,8 +7985,22 @@ use Transformers qw(make_checksum parse_timestamp);
|
||||
|
||||
use constant PTDEBUG => $ENV{PTDEBUG} || 0;
|
||||
|
||||
our $pretty_json = undef;
|
||||
our $sorted_json = undef;
|
||||
|
||||
extends qw(QueryReportFormatter);
|
||||
|
||||
has _json => (
|
||||
is => 'ro',
|
||||
init_arg => undef,
|
||||
builder => '_build_json',
|
||||
handles => { encode_json => 'encode' },
|
||||
);
|
||||
|
||||
sub _build_json {
|
||||
return JSON->new->utf8->pretty($pretty_json)->canonical($sorted_json);
|
||||
}
|
||||
|
||||
override [qw(rusage date hostname files header profile prepared)] => sub {
|
||||
return;
|
||||
};
|
||||
@@ -8062,7 +8076,7 @@ override query_report => sub {
|
||||
};
|
||||
}
|
||||
|
||||
return encode_json(\@queries) . "\n";
|
||||
return $self->encode_json(\@queries) . "\n";
|
||||
};
|
||||
|
||||
1;
|
||||
|
Reference in New Issue
Block a user