Skip to content
Emanuele Minotto edited this page Nov 30, 2024 · 3 revisions

Crystal provides a logger to help developer tracking informations.
The logger is provided in two different ways based on the PHP version that's used, if it's on PHP 5 the logger is provided as a function, if it's on PHP 7 or newer versions it's provided as an object with an interface similar to the interface provided by PSR-3.

Both the implementations use syslog, so you can manage the implementation through openlog.

PHP 5 version

$mf(function () use ($mf) {
    $logger = $mf('logger');

    $logger('info', 'lorem ipsum', array(
        'foo' => true,
    ));
    $logger('debug', 'dolor sit amet');
});

PHP 7+ version

$mf(function () use ($mf) {
    $logger = $mf('logger');

    $logger->info('lorem ipsum', [
        'foo' => true,
    ]);
    $logger->debug('dolor sit amet');
});
Clone this wiki locally