Skip to content

robertsaupe/php-logger

Repository files navigation

php-logger

Minimum PHP version: 8.2 Packagist Version Packagist Downloads License

php library to create a logger

Supporting

GitHub | Patreon | PayPal | Amazon

Installing

composer require robertsaupe/php-logger

Getting started

Basic

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));

File

use robertsaupe\Logger\LogFile;

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

//now writes the messages to a log-file

HTML

use robertsaupe\Logger\LogHTML;

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

//now writes the messages to a html-file

Credits