mirror of
https://github.com/YGGverse/YGGtracker.git
synced 2025-01-11 15:37:57 +00:00
add log settings for scrape and sitemap crontab tasks
This commit is contained in:
parent
68a7471a8a
commit
3e70bc9c2a
@ -179,6 +179,12 @@ define('API_IMPORT_MAGNET_VIEWS_ENABLED', true); // depends of API_IMP
|
||||
// Logs
|
||||
define('LOG_DIRECTORY', __DIR__ . '/../storage/log');
|
||||
|
||||
define('LOG_CRONTAB_SCRAPE_ENABLED', true);
|
||||
define('LOG_CRONTAB_SCRAPE_FILENAME', sprintf('crontab_scrape_%s.log', date('Y-m-d')));
|
||||
|
||||
define('LOG_CRONTAB_SITEMAP_ENABLED', true);
|
||||
define('LOG_CRONTAB_SITEMAP_FILENAME', sprintf('crontab_sitemap_%s.log', date('Y-m-d')));
|
||||
|
||||
define('LOG_CRONTAB_EXPORT_FEED_ENABLED', true);
|
||||
define('LOG_CRONTAB_EXPORT_FEED_FILENAME', sprintf('crontab_export_feed_%s.log', date('Y-m-d')));
|
||||
|
||||
|
@ -17,6 +17,16 @@ $debug = [
|
||||
'ISO8601' => date('c'),
|
||||
'total' => microtime(true),
|
||||
],
|
||||
'http' =>
|
||||
[
|
||||
'total' => 0,
|
||||
],
|
||||
'memory' =>
|
||||
[
|
||||
'start' => memory_get_usage(),
|
||||
'total' => 0,
|
||||
'peaks' => 0
|
||||
],
|
||||
];
|
||||
|
||||
// Init Scraper
|
||||
@ -121,17 +131,28 @@ try {
|
||||
}
|
||||
|
||||
// Debug output
|
||||
$debug['time']['total'] = microtime(true) - $debug['time']['total'];
|
||||
$debug['time']['total'] = microtime(true) - $debug['time']['total'];
|
||||
|
||||
print_r(
|
||||
array_merge($debug, [
|
||||
'db' => [
|
||||
'total' => [
|
||||
'select' => $db->getDebug()->query->select->total,
|
||||
'insert' => $db->getDebug()->query->insert->total,
|
||||
'update' => $db->getDebug()->query->update->total,
|
||||
'delete' => $db->getDebug()->query->delete->total,
|
||||
]
|
||||
]
|
||||
])
|
||||
);
|
||||
$debug['memory']['total'] = memory_get_usage() - $debug['memory']['start'];
|
||||
$debug['memory']['peaks'] = memory_get_peak_usage();
|
||||
|
||||
$debug['db']['total']['select'] = $db->getDebug()->query->select->total;
|
||||
$debug['db']['total']['insert'] = $db->getDebug()->query->insert->total;
|
||||
$debug['db']['total']['update'] = $db->getDebug()->query->update->total;
|
||||
$debug['db']['total']['delete'] = $db->getDebug()->query->delete->total;
|
||||
|
||||
print_r($debug);
|
||||
|
||||
// Debug log
|
||||
if (LOG_CRONTAB_SCRAPE_ENABLED)
|
||||
{
|
||||
@mkdir(LOG_DIRECTORY, 0774, true);
|
||||
|
||||
if ($handle = fopen(LOG_DIRECTORY . '/' . LOG_CRONTAB_SCRAPE_FILENAME, 'a+'))
|
||||
{
|
||||
fwrite($handle, print_r($debug, true));
|
||||
fclose($handle);
|
||||
|
||||
chmod(LOG_DIRECTORY . '/' . LOG_CRONTAB_SCRAPE_FILENAME, 0774);
|
||||
}
|
||||
}
|
@ -17,6 +17,16 @@ $debug = [
|
||||
'ISO8601' => date('c'),
|
||||
'total' => microtime(true),
|
||||
],
|
||||
'http' =>
|
||||
[
|
||||
'total' => 0,
|
||||
],
|
||||
'memory' =>
|
||||
[
|
||||
'start' => memory_get_usage(),
|
||||
'total' => 0,
|
||||
'peaks' => 0
|
||||
],
|
||||
];
|
||||
|
||||
// Begin
|
||||
@ -49,17 +59,28 @@ try {
|
||||
}
|
||||
|
||||
// Debug output
|
||||
$debug['time']['total'] = microtime(true) - $debug['time']['total'];
|
||||
$debug['time']['total'] = microtime(true) - $debug['time']['total'];
|
||||
|
||||
print_r(
|
||||
array_merge($debug, [
|
||||
'db' => [
|
||||
'total' => [
|
||||
'select' => $db->getDebug()->query->select->total,
|
||||
'insert' => $db->getDebug()->query->insert->total,
|
||||
'update' => $db->getDebug()->query->update->total,
|
||||
'delete' => $db->getDebug()->query->delete->total,
|
||||
]
|
||||
]
|
||||
])
|
||||
);
|
||||
$debug['memory']['total'] = memory_get_usage() - $debug['memory']['start'];
|
||||
$debug['memory']['peaks'] = memory_get_peak_usage();
|
||||
|
||||
$debug['db']['total']['select'] = $db->getDebug()->query->select->total;
|
||||
$debug['db']['total']['insert'] = $db->getDebug()->query->insert->total;
|
||||
$debug['db']['total']['update'] = $db->getDebug()->query->update->total;
|
||||
$debug['db']['total']['delete'] = $db->getDebug()->query->delete->total;
|
||||
|
||||
print_r($debug);
|
||||
|
||||
// Debug log
|
||||
if (LOG_CRONTAB_SITEMAP_ENABLED)
|
||||
{
|
||||
@mkdir(LOG_DIRECTORY, 0774, true);
|
||||
|
||||
if ($handle = fopen(LOG_DIRECTORY . '/' . LOG_CRONTAB_SITEMAP_FILENAME, 'a+'))
|
||||
{
|
||||
fwrite($handle, print_r($debug, true));
|
||||
fclose($handle);
|
||||
|
||||
chmod(LOG_DIRECTORY . '/' . LOG_CRONTAB_SITEMAP_FILENAME, 0774);
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user