Commit 01d8260f authored by Michael Iseard's avatar Michael Iseard
Browse files

Add ellipsis to message/context if longer than 255 chars

parent 5874621a
......@@ -292,4 +292,19 @@ class Utils {
return $image_url;
}
/**
* Truncates string at specified length and return with ellipsis
* if longer.
*
* @param string $string
* @param int $length
*
* @return string
*/
public static function truncate_string(string $string, int $length): string {
return strlen($string) > $length ? substr($string, 0, $length) . "..." : $string;
}
}
<?php
use Kudos\Helpers\Utils;
use Kudos\Service\LoggerService;
/**
......@@ -93,10 +94,10 @@ $tab = $_GET['tab'] ?? $default_tab;
<?php echo esc_attr( $level ); ?>
</td>
<td title="<?php echo( $message ); ?>">
<?php echo( substr( $message, 0, 255 ) ); ?>
<?php echo( Utils::truncate_string($message, 255) ); ?>
</td>
<td title="<?php echo( $context ); ?>">
<?php echo( substr( $context, 0, 255 ) ); ?>
<?php echo( Utils::truncate_string($context, 255) ); ?>
</td>
</tr>
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment