diff --git a/dev/Backtrace.php b/dev/Backtrace.php index 1426bf544..89c18ee8c 100644 --- a/dev/Backtrace.php +++ b/dev/Backtrace.php @@ -75,8 +75,13 @@ class SS_Backtrace { /** * Return the full function name. If showArgs is set to true, a string representation of the arguments will be shown + * + * @param Object $item + * @param boolean $showArg + * @param Int $argCharLimit + * @return String */ - static function full_func_name($item, $showArgs = false) { + static function full_func_name($item, $showArgs = false, $argCharLimit = 10000) { $funcName = ''; if(isset($item['class'])) $funcName .= $item['class']; if(isset($item['type'])) $funcName .= $item['type']; @@ -86,7 +91,7 @@ class SS_Backtrace { $args = array(); foreach($item['args'] as $arg) { if(!is_object($arg) || method_exists($arg, '__toString')) { - $args[] = (string) $arg; + $args[] = (strlen((string)$arg) > $argCharLimit) ? substr((string)$arg, 0, $argCharLimit) . '...' : (string)$arg; } else { $args[] = get_class($arg); } diff --git a/tests/dev/BacktraceTest.php b/tests/dev/BacktraceTest.php new file mode 100644 index 000000000..a7a01ff4b --- /dev/null +++ b/tests/dev/BacktraceTest.php @@ -0,0 +1,26 @@ + 'MyClass', + 'type' => '->', + 'file' => 'MyFile.php', + 'line' => 99, + 'function' => 'myFunction', + 'args' => array( + 'number' => 1, + 'mylongstring' => 'more than 20 characters 1234567890', + ) + ); + $this->assertEquals( + 'MyClass->myFunction(1,more than 20 charact...)', + SS_Backtrace::full_func_name($func, true, 20) + ); + } + +} \ No newline at end of file