PHP code example of larsgmortensen / litelog

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

    

larsgmortensen / litelog example snippets


use LiteLog\LiteLog;

use LiteLog\LiteLog;

// Configure once at bootstrap
LiteLog::setDefaultDir('/path/to/logs');
LiteLog::setMaxFileSize(10 * 1024 * 1024); // 10 MB
LiteLog::setMaxRotatedFiles(5);            // keep 5 rotated files

// Write a log line
LiteLog::log(
    'app.json',  // Log filename (relative to log dir)
    'info',  // Category
    'Coffee supply is critically low',  // Message (string or array)
    ['cups_left' => 1, 'developer' => 'Sleepy']  // Context (optional)
);

LiteLog::setDefaultDir(string $dir, bool $createIfMissing = false): void
LiteLog::setMaxFileSize(int $bytes): void
LiteLog::setMaxRotatedFiles(?int $count): void
LiteLog::log(string $file, string $category, string|array|object $message, array $context = []): void