PHP code example of meusistemabr / ci4-sqlite-logger

1. Go to this page and download the library: Download meusistemabr/ci4-sqlite-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/ */

    

meusistemabr / ci4-sqlite-logger example snippets


  ...
  ...
  ...
  ...
  ... // bastante codigo acima e algumas instruções
  SqliteHandler::class => [
        'handles' => [
            'critical',
            'alert',
            'emergency',
            'debug',
            'error',
            'info',
            'notice',
            'warning',
        ],
        'dbPath'       => WRITEPATH . 'database/system_logs.db',
        'maxFileSize'  => 10 * 1024 * 1024,
        'reportErrors' => true,
        'throwOnError' => false,
        'type'         => 'system',
    ],

msbr_log('warning', 'Falha ao processar pagamento', [
    'order_id'     => 123,
    'gateway'      => 'pagarme',
    'cluster_id'   => 3,
    'port_origin'  => '1234'
]);

msbr_audit(
    'update',
    'Cadastro de Clientes',
    'Cliente alterado',
    [
        'user_id'   => auth()->user()->id ?? null,
        'table'     => 'clientes',
        'record_id' => $clienteId,
        'old'       => $oldData,
        'new'       => $newData,
    ]
);

msbr_audit(
    string $action,
    string $area,
    string $message,
    array $data = [],
    string $level = 'warning',
    array $config = []
): bool

WRITEPATH . 'database/system_logs.db'

$handler = msbr_sqlite_logger();

$okSystem = $handler?->verifyIntegrity('system_logs');
$okAudit  = $handler?->verifyIntegrity('audit_logs');

'throwOnError' => true,

'throwOnError' => false,
bash
composer dump-autoload
php spark optimize:clear
app/Config/Logger.php
bash
php spark logs:tail
bash
php spark logs:tail 25