Skip to content

Commit 0304efb

Browse files
committed
Update format_table to add option for skipping log file
Signed-off-by: Riddhesh Sanghvi <[email protected]>
1 parent 383f773 commit 0304efb

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

php/utils.php

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1508,19 +1508,25 @@ function get_type( $assoc_args, $arg_types, $default = false ) {
15081508
* # +------+--------+
15091509
* ```
15101510
*
1511-
* @param array $items An array of items to output.
1511+
* @param array $items An array of items to output.
1512+
* @param bool $log_data To log table in file or not.
15121513
*
15131514
*/
1514-
function format_table( $items ) {
1515+
function format_table( $items, $log_in_file = false ) {
15151516
$item_table = new \cli\Table();
15161517
$item_table->setRows( $items );
15171518
$item_table->setRenderer( new \cli\table\Ascii() );
15181519
$lines = array_slice( $item_table->getDisplayLines(), 3 );
15191520
array_pop( $lines );
15201521
$delem = $item_table->getDisplayLines()[0];
15211522
foreach ( $lines as $line ) {
1522-
\EE::log( $delem );
1523-
\EE::log( $line );
1523+
if ( $log_in_file ) {
1524+
\EE::log( $delem );
1525+
\EE::log( $line );
1526+
} else {
1527+
\EE::line( $delem );
1528+
\EE::line( $line );
1529+
}
15241530
}
15251531
\EE::log( $delem );
15261532
}

0 commit comments

Comments
 (0)