PHP code example of maatify / slim-logger

1. Go to this page and download the library: Download maatify/slim-logger library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

maatify / slim-logger example snippets


use Maatify\SlimLogger\Log\Logger;
use Maatify\SlimLogger\Log\LogLevelEnum;
use Maatify\SlimLogger\Store\File\Path;

$logger = new Logger(new Path(__DIR__));
$logger->record('User login', null, 'user/actions', LogLevelEnum::Info);

$app->post('/action', function ($request, $response) use ($logger) {
    $logger->record('User posted action.', $request, 'user/submit', LogLevelEnum::Debug);
    return $response;
});

try {
    throw new \Exception('Oops');
} catch (\Throwable $e) {
    $logger->record($e, null, 'errors/runtime', LogLevelEnum::Error);
}

use Maatify\SlimLogger\Log\Logger;
use Maatify\SlimLogger\Log\LogLevelEnum;

Logger::recordStatic('Static log entry.', null, 'system/status', LogLevelEnum::Info);

try {
    throw new \Exception("Static exception!");
} catch (\Throwable $e) {
    Logger::recordStatic($e, null, 'errors/fatal', LogLevelEnum::Error);
}

$testLogger = new Logger(new Path(__DIR__ . '/logs'));
Logger::setInstance($testLogger);

maatify-slim-logger/
├── src/
│   └── Log/
│       ├── Logger.php
│       └── LogLevelEnum.php
│   └── Store/
│       └── File/
│           └── Path.php