Configuration de Tracy

Les exemples suivants supposent que l'alias de classe suivant est défini :

use Tracy\Debugger;

Enregistrement des erreurs

$logger = Debugger::getLogger();

// if error has occurred the notification is sent to this email
$logger->email = 'dev@example.com';      // (string|string[]) defaults to unset

// email sender
$logger->fromEmail = 'me@example.com';   // (string) defaults to unset

// routine for sending email
$logger->mailer = /* ... */;             // (callable) default it sending by mail()

// after what shortest time to send another email?
$logger->emailSnooze = /* ... */;        // (string) default is '2 days'

// for which error levels is BlueScreen also logged?
Debugger::$logSeverity = E_WARNING | E_NOTICE;  // defaults to 0 (no error level)

dump() Comportement

// maximum string length
Debugger::$maxLength = 150;              // (int) default according to Tracy

// how deep will list
Debugger::$maxDepth = 10;                // (int) default according to Tracy

// hide values of these keys (since Tracy 2.8)
Debugger::$keysToHide = ['password', /* ... */];  // (string[]) defaults to []

// visual theme (since Tracy 2.8)
Debugger::$dumpTheme = 'dark';           // (light|dark) defaults to 'light'

// displays the location where dump() was called?
Debugger::$showLocation = /* ... */;     // (bool) default according to Tracy

Autres

// in Development mode, you will see notice or error warnings as BlueScreen
Debugger::$strictMode = /* ... */;       // (bool|int) defaults to false, you can select only specific error levels (e.g. E_USER_DEPRECATED | E_DEPRECATED)

// displays silent (@) error messages
Debugger::$scream = /* ... */;           // (bool|int) defaults to false, since version 2.9 it is possible to select only specific error levels (e.g. E_USER_DEPRECATED | E_DEPRECATED)

// link format to open in the editor
Debugger::$editor = /* ... */;           // (string|null) defaults to 'editor://open/?file=%file&line=%line'

// path to template with custom page for error 500
Debugger::$errorTemplate = /* ... */;    // (string) defaults to unset

// shows Tracy Bar?
Debugger::$showBar = /* ... */;          // (bool) defaults to true

Debugger::$editorMapping = [
	// original => new
	'/var/www/html' => '/data/web',
	'/home/web' => '/srv/html',
];

Cadre de Nette

Si vous utilisez le Nette Framework, vous pouvez également configurer Tracy et ajouter de nouveaux panneaux à la barre Tracy à l'aide du fichier de configuration. Vous pouvez définir les paramètres de Tracy dans la configuration et également ajouter de nouveaux panneaux à la barre Tracy. Ces paramètres ne sont appliqués qu'après la création du conteneur DI, de sorte que les erreurs survenues plus tôt ne peuvent pas les refléter.

Configuration de l'enregistrement des erreurs :

tracy:
	# if error has occurred the notification is sent to this email
	email: dev@example.com           # (string|string[]) defaults to unset

	# email sender
	fromEmail: robot@example.com     # (string) defaults to unset

	# period of postponement of emails sending (since Tracy 2.8.8)
	emailSnooze: ...                 # (string) defaults to '2 days'

	# to use a mailer defined in the configuration? (since Tracy 2.5)
	netteMailer: ...                 # (bool) defaults to true

	# for which error levels is BlueScreen also logged?
	logSeverity: [E_WARNING, E_NOTICE]  # defaults to []

Configuration pour la fonction dump():

tracy:
	# maximum string length
	maxLength: 150                # (int) default according to Tracy

	# how deep will list
	maxDepth: 10                  # (int) default according to Tracy

	# hide values of these keys (since Tracy 2.8)
	keysToHide: [password, pass]  # (string[]) defaults to []

	# visual theme (since Tracy 2.8)
	dumpTheme: dark               # (light|dark) defaults to 'light'

	# displays the location where dump() was called?
	showLocation: ...             # (bool) default according to Tracy

Pour installer l'extension Tracy :

tracy:
	# appends bars to Tracy Bar
	bar:
		- Nette\Bridges\DITracy\ContainerPanel
		- IncludePanel
		- XDebugHelper('myIdeKey')
		- MyPanel(@MyService)

	# append panels to BlueScreen
	blueScreen:
		- DoctrinePanel::renderException

Autres options :

tracy:
	# in Development mode, you will see notice or error warnings as BlueScreen
	strictMode: ...           # defaults to true

	# displays silent (@) error messages
	scream: ...               # defaults to false

	# link format to open in the editor
	editor: ...               # (string) defaults to 'editor://open/?file=%file&line=%line'

	# path to template with custom page for error 500
	errorTemplate: ...        # (string) defaults to unset

	# shows Tracy Bar?
	showBar: ...              # (bool) defaults to true

	editorMapping:
		# original: new
		/var/www/html: /data/web
		/home/web: /srv/html

Les valeurs des options logSeverity, strictMode et scream peuvent être écrites comme un tableau de niveaux d'erreur (par ex. [E_WARNING, E_NOTICE]) ou comme une expression utilisée en PHP (par exemple, E_ALL & ~E_NOTICE).

Services DI

Ces services sont ajoutés au conteneur DI :

Nom Type Description
tracy.logger Tracy\ILogger logger
tracy.blueScreen Tracy\BlueScreen BlueScreen
tracy.bar Tracy\Bar Barre Tracy