BASE . LOG,
'log_file_id' => $LOG_FILE_ID,
'log_level' => Level::Debug,
'log_per_date' => true,
]);
$PAGE_NAME = 'TEST CLASS: LOGGING';
print "";
print "
" . $PAGE_NAME . "";
print "";
print '';
print '' . $PAGE_NAME . '
';
$log->logger2Debug();
echo "
";
print "Level 250: " . Level::fromValue(250)->getName() . "
";
print "Flag: per_class (16) (from int): " . Flag::fromValue(16)->getName() . "
";
print "Flag: per_class getName(): " . Flag::per_class->getName() . "
";
print "Flag: per_class ->name: " . Flag::per_class->name . "
";
print "Flag: per_class ->value: " . Flag::per_class->value . "
";
$log->setLogUniqueId();
print "LogUniqId: " . $log->getLogUniqueId() . "
";
print "Is Debug (check): " . Support::printBool($log->getLoggingLevel()->includes(
Level::Debug
)) . "
";
print "Is Debug (fk): " . Support::printBool($log->loggingLevelIsDebug()) . "
";
$log->setLoggingLevel(Level::Notice);
print "Is Debug (check): " . Support::printBool($log->getLoggingLevel()->includes(
Level::Debug
)) . "
";
print "Is Debug (fk): " . Support::printBool($log->loggingLevelIsDebug()) . "
";
$log->setLoggingLevel(Level::Debug);
print "DUMP: " . $log->dV(['something' => 'error']) . "
";
$log->debug('LEGACY', 'Some legacy shit here');
$log->debug('ARRAY', 'Dump some data: ' . $log->dV(['something' => 'error']));
$log->debug('MIXED', 'Dump mixed: ' . $log->dV(<<block
and > and <
EOM));
$log->info('Info message', ['info' => 'log']);
$log->notice('Notice message', ['notice' => 'log']);
$log->warning('Warning message', ['warning' => 'log']);
$log->error('Cannot process data', ['error' => 'log']);
$log->critical('Critical message', ['critical' => 'log']);
$log->alert('Alert message', ['Alert' => 'log']);
$log->emergency('Emergency message', ['Emergency' => 'log']);
error_log('TRIGGER ERROR LOG MANUAL: Emergency');
print "Log File: " . $log->getLogFile() . "
";
$log->setLogFlag(Flag::per_run);
$log->debug('PER RUN', 'per run logging');
print "Log File: " . $log->getLogFile() . "
";
$log->unsetLogFlag(Flag::per_run);
// init empty
unset($LOG_FILE_ID);
$ll = new CoreLibs\Logging\Logging([
'log_folder' => BASE . LOG,
]);
print "LFI: " . $ll->getLogFileId() . "
";
try {
$ll->setLoggingLevel('Invalid');
} catch (\Psr\Log\InvalidArgumentException $e) {
print "Invalid option: " . $e->getMessage() . "
";
}
/* $ll = new CoreLibs\Logging\Logging([
'log_folder' => BASE . LOG,
'log_file_id' => 'a',
'log_file_id' => 'a',
]); */
// @codingStandardsIgnoreLine
Class TestP
{
/** @var \CoreLibs\Logging\Logging */
public $log;
public function __construct(
\CoreLibs\Logging\Logging $log
) {
$this->log = $log;
}
public function test(): void
{
$this->log->info('TestL::test call');
}
}
$tl = new TestP($log);
$tl->test();
print '
'
. ''
// . '
'
. nl2br(htmlentities(file_get_contents($log->getLogFolder() . $log->getLogFile()) ?: ''))
// . '
'
. '
';
print "