PHP code example of robertsaupe / php-logger

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

    

robertsaupe / php-logger example snippets


use robertsaupe\Logger\LogBasic;

$logger = new LogBasic();

$logger->error('error');
$logger->warning('warning');
$logger->info('info');
$logger->normal('normal');
$logger->verbose('verbose');
$logger->veryverbose('veryverbose');
$logger->debug('debug');

//return messageObject
$message = $logger->normal("Testmessage");
print_r($message);
print_r($message->getArray());

//return all messages
print($logger->getFormattedMessagesByVerbosity());

//return all messages as html
print($logger->getFormattedMessagesByVerbosity(true));

use robertsaupe\Logger\LogFile;

$logger = new LogFile(dirname(__DIR__).'/logs', 'test');

//now writes the messages to a log-file

use robertsaupe\Logger\LogHTML;

$logger = new LogHTML(dirname(__DIR__).'/logs', 'test');

//now writes the messages to a html-file