Skip to content

Commit

Permalink
Debugger::$maxLen ⇒ $maxLength
Browse files Browse the repository at this point in the history
  • Loading branch information
dg committed Jun 16, 2016
1 parent e98158d commit 12d5caf
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
4 changes: 2 additions & 2 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -171,11 +171,11 @@ generates the output:

![dump](https://nette.github.io/tracy/images/tracy-dump.png)

You can also change the nesting depth by `Debugger::$maxDepth` and displayed strings length by `Debugger::$maxLen`. Naturally, lower values accelerate Tracy rendering.
You can also change the nesting depth by `Debugger::$maxDepth` and displayed strings length by `Debugger::$maxLength`. Naturally, lower values accelerate Tracy rendering.

```php
Debugger::$maxDepth = 2; // default: 3
Debugger::$maxLen = 50; // default: 150
Debugger::$maxLength = 50; // default: 150
```

The `dump()` function can display other useful information. `Tracy\Dumper::LOCATION_SOURCE` adds tooltip with path to the file, where the function was called. `Tracy\Dumper::LOCATION_LINK` adds a link to the file. `Tracy\Dumper::LOCATION_CLASS` adds a tooltip to every dumped object containing path to the file, in which the object's class is defined. All these constants can be set in `Debugger::$showLocation` variable before calling the `dump()`. You can set multiple values at once using the `|` operator.
Expand Down
12 changes: 8 additions & 4 deletions src/Tracy/Debugger.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,11 +58,14 @@ class Debugger
public static $maxDepth = 3;

/** @var int how long strings display {@link Debugger::dump()} */
public static $maxLen = 150;
public static $maxLength = 150;

/** @var bool display location? {@link Debugger::dump()} */
public static $showLocation = FALSE;

/** @deprecated */
public static $maxLen = 150;

/********************* logging ****************d*g**/

/** @var string name of the directory where errors should be logged */
Expand Down Expand Up @@ -140,6 +143,7 @@ public static function enable($mode = NULL, $logDirectory = NULL, $email = NULL)
self::$productionMode = is_bool($mode) ? $mode : !self::detectDebugMode($mode);
}

self::$maxLen = & self::$maxLength;
self::$reserved = str_repeat('t', 3e5);
self::$time = isset($_SERVER['REQUEST_TIME_FLOAT']) ? $_SERVER['REQUEST_TIME_FLOAT'] : microtime(TRUE);
self::$obLevel = ob_get_level();
Expand Down Expand Up @@ -506,14 +510,14 @@ public static function dump($var, $return = FALSE)
ob_start(function () {});
Dumper::dump($var, [
Dumper::DEPTH => self::$maxDepth,
Dumper::TRUNCATE => self::$maxLen,
Dumper::TRUNCATE => self::$maxLength,
]);
return ob_get_clean();

} elseif (!self::$productionMode) {
Dumper::dump($var, [
Dumper::DEPTH => self::$maxDepth,
Dumper::TRUNCATE => self::$maxLen,
Dumper::TRUNCATE => self::$maxLength,
Dumper::LOCATION => self::$showLocation,
]);
}
Expand Down Expand Up @@ -554,7 +558,7 @@ public static function barDump($var, $title = NULL, array $options = NULL)
}
$panel->data[] = ['title' => $title, 'dump' => Dumper::toHtml($var, (array) $options + [
Dumper::DEPTH => self::$maxDepth,
Dumper::TRUNCATE => self::$maxLen,
Dumper::TRUNCATE => self::$maxLength,
Dumper::LOCATION => self::$showLocation ?: Dumper::LOCATION_CLASS | Dumper::LOCATION_SOURCE,
])];
}
Expand Down

0 comments on commit 12d5caf

Please sign in to comment.