PHP code example of onnerby / doelogger

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

    

onnerby / doelogger example snippets


// Initialize the log by
\Doe\Logger::addDefaultStream('/var/log/mylog')

// The anywhere in your code
\Doe\Logger::write('adduser', 'Added a new user', $user);


// Initialize the log by
\Doe\Logger::addDefaultStream('/var/log/mylog')

// Get a reader for the last 24 hours
$logReader = \Doe\Logger::reader('default', microtime(true) - 60*60*24);

// Loop through the log
foreach ($logReader as $logEntry) {
	echo "Log " . date('Y-m-d H:i:s', $logEntry['when']) . ' ' . $logEntry['type'] . "\n";
	echo "  User: " . json_encode($logEntry['content'][0]) . "\n";
}