Skip to content

Instantly share code, notes, and snippets.

@wowo
Last active September 3, 2019 19:38
Show Gist options
  • Save wowo/936078e0b626122aee71a242539dfa47 to your computer and use it in GitHub Desktop.
Save wowo/936078e0b626122aee71a242539dfa47 to your computer and use it in GitHub Desktop.
log-demo

Installation:

git clone [email protected]:936078e0b626122aee71a242539dfa47.git log-demo
cd log-demo
composer install
php index.php
{
"name": "wowo/log-demo",
"type": "project",
"require": {
"monolog/monolog": "^2.0"
},
"authors": [
{
"name": "Wojciech Sznapka",
"email": "[email protected]"
}
]
}
<?php
require __DIR__.'/vendor/autoload.php';
use Monolog\Logger;
use Monolog\Handler\StreamHandler;
use Monolog\Processor\MemoryPeakUsageProcessor;
use Monolog\Processor\MemoryUsageProcessor;
$log = new Logger(basename(__DIR__));
$log
->pushHandler(new StreamHandler('php://stdout', Logger::INFO))
->pushProcessor(new MemoryUsageProcessor())
->pushProcessor(new MemoryPeakUsageProcessor());
$log->info('Starting');
$randomNumbers = [];
for ($i = 0; $i < 1234567; $i++) {
$randomNumbers[] = rand();
}
$log->info('Got 1st batch of numbers');
unset($randomNumbers);
$randomNumbers = [];
$log->info('Erased');
for ($i = 0; $i < 2 * 1234567; $i++) {
$randomNumbers[] = rand();
}
$log->info('Got 2nd batch of numbers');
echo '¯\_(ツ)_/¯' . PHP_EOL;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment