mirror of
https://github.com/YGGverse/YGGtracker.git
synced 2025-01-08 22:17:57 +00:00
add log support
This commit is contained in:
parent
1998e73515
commit
94b1ca5700
4
.gitignore
vendored
4
.gitignore
vendored
@ -6,13 +6,15 @@
|
||||
|
||||
/src/public/api/*.json
|
||||
|
||||
/src/config/*
|
||||
/src/config/
|
||||
!/src/config/bootstrap.php
|
||||
!/src/config/nodes.php
|
||||
!/src/config/trackers.php
|
||||
|
||||
/src/public/sitemap.xml
|
||||
|
||||
/src/storage/log/*.log
|
||||
|
||||
/composer.lock
|
||||
|
||||
*test*
|
@ -174,4 +174,19 @@ define('API_IMPORT_MAGNET_DOWNLOADS_ENABLED', true); // depends of API_IMP
|
||||
define('API_IMPORT_MAGNET_COMMENTS_ENABLED', true); // depends of API_IMPORT_ENABLED, API_IMPORT_USERS_ENABLED, API_IMPORT_MAGNETS_ENABLED
|
||||
define('API_IMPORT_MAGNET_COMMENTS_APPROVED_ONLY', false); // depends of API_IMPORT_ENABLED, API_IMPORT_USERS_ENABLED, API_IMPORT_MAGNETS_ENABLED, API_IMPORT_MAGNET_COMMENTS_ENABLED
|
||||
define('API_IMPORT_MAGNET_STARS_ENABLED', true); // depends of API_IMPORT_ENABLED, API_IMPORT_USERS_ENABLED, API_IMPORT_MAGNETS_ENABLED
|
||||
define('API_IMPORT_MAGNET_VIEWS_ENABLED', true); // depends of API_IMPORT_ENABLED, API_IMPORT_USERS_ENABLED, API_IMPORT_MAGNETS_ENABLED
|
||||
define('API_IMPORT_MAGNET_VIEWS_ENABLED', true); // depends of API_IMPORT_ENABLED, API_IMPORT_USERS_ENABLED, API_IMPORT_MAGNETS_ENABLED
|
||||
|
||||
// Logs
|
||||
define('LOG_DIRECTORY', __DIR__ . '/../storage/log');
|
||||
|
||||
define('LOG_CRONTAB_EXPORT_FEED_ENABLED', true);
|
||||
define('LOG_CRONTAB_EXPORT_FEED_FILENAME', sprintf('crontab_export_feed_%s.log', date('Y-m-d')));
|
||||
|
||||
define('LOG_CRONTAB_EXPORT_PUSH_ENABLED', true);
|
||||
define('LOG_CRONTAB_EXPORT_PUSH_FILENAME', sprintf('crontab_export_push_%s.log', date('Y-m-d')));
|
||||
|
||||
define('LOG_CRONTAB_IMPORT_FEED_ENABLED', true);
|
||||
define('LOG_CRONTAB_IMPORT_FEED_FILENAME', sprintf('crontab_import_feed_%s.log', date('Y-m-d')));
|
||||
|
||||
define('LOG_API_PUSH_ENABLED', true);
|
||||
define('LOG_API_PUSH_FILENAME', sprintf('api_push_%s.log', date('Y-m-d')));
|
@ -5,7 +5,7 @@ $semaphore = sem_get(crc32('yggtracker.crontab.export.feed'), 1);
|
||||
|
||||
if (false === sem_acquire($semaphore, true))
|
||||
{
|
||||
exit (PHP_EOL . 'yggtracker.crontab.export.feed process locked by another thread.' . PHP_EOL);
|
||||
exit (_('yggtracker.crontab.export.feed process locked by another thread.'));
|
||||
}
|
||||
|
||||
// Bootstrap
|
||||
@ -14,10 +14,21 @@ require_once __DIR__ . '/../../config/bootstrap.php';
|
||||
// Init Debug
|
||||
$debug =
|
||||
[
|
||||
'dump' => [],
|
||||
'time' => [
|
||||
'ISO8601' => date('c'),
|
||||
'total' => microtime(true),
|
||||
],
|
||||
'http' =>
|
||||
[
|
||||
'total' => 0,
|
||||
],
|
||||
'memory' =>
|
||||
[
|
||||
'start' => memory_get_usage(),
|
||||
'total' => 0,
|
||||
'peaks' => 0
|
||||
],
|
||||
];
|
||||
|
||||
// Define public registry
|
||||
@ -519,17 +530,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_EXPORT_FEED_ENABLED)
|
||||
{
|
||||
@mkdir(LOG_DIRECTORY, 0770, true);
|
||||
|
||||
if ($handle = fopen(LOG_DIRECTORY . '/' . LOG_CRONTAB_EXPORT_FEED_FILENAME, 'a+'))
|
||||
{
|
||||
fwrite($handle, print_r($debug, true));
|
||||
fclose($handle);
|
||||
|
||||
chmod(LOG_DIRECTORY . '/' . LOG_CRONTAB_EXPORT_FEED_FILENAME, 0770);
|
||||
}
|
||||
}
|
@ -14,12 +14,21 @@ require_once __DIR__ . '/../../config/bootstrap.php';
|
||||
// Init Debug
|
||||
$debug =
|
||||
[
|
||||
'time' =>
|
||||
[
|
||||
'dump' => [],
|
||||
'time' => [
|
||||
'ISO8601' => date('c'),
|
||||
'total' => microtime(true),
|
||||
],
|
||||
'result' => []
|
||||
'http' =>
|
||||
[
|
||||
'total' => 0,
|
||||
],
|
||||
'memory' =>
|
||||
[
|
||||
'start' => memory_get_usage(),
|
||||
'total' => 0,
|
||||
'peaks' => 0
|
||||
],
|
||||
];
|
||||
|
||||
// Define public registry
|
||||
@ -365,17 +374,28 @@ else
|
||||
}
|
||||
|
||||
// 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_EXPORT_PUSH_ENABLED)
|
||||
{
|
||||
@mkdir(LOG_DIRECTORY, 0770, true);
|
||||
|
||||
if ($handle = fopen(LOG_DIRECTORY . '/' . LOG_CRONTAB_EXPORT_PUSH_FILENAME, 'a+'))
|
||||
{
|
||||
fwrite($handle, print_r($debug, true));
|
||||
fclose($handle);
|
||||
|
||||
chmod(LOG_DIRECTORY . '/' . LOG_CRONTAB_EXPORT_PUSH_FILENAME, 0770);
|
||||
}
|
||||
}
|
@ -1141,4 +1141,18 @@ $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);
|
||||
print_r($debug);
|
||||
|
||||
// Debug log
|
||||
if (LOG_CRONTAB_IMPORT_FEED_ENABLED)
|
||||
{
|
||||
@mkdir(LOG_DIRECTORY, 0770, true);
|
||||
|
||||
if ($handle = fopen(LOG_DIRECTORY . '/' . LOG_CRONTAB_IMPORT_FEED_FILENAME, 'a+'))
|
||||
{
|
||||
fwrite($handle, print_r($debug, true));
|
||||
fclose($handle);
|
||||
|
||||
chmod(LOG_DIRECTORY . '/' . LOG_CRONTAB_IMPORT_FEED_FILENAME, 0770);
|
||||
}
|
||||
}
|
0
src/storage/log/index.html
Normal file
0
src/storage/log/index.html
Normal file
Loading…
Reference in New Issue
Block a user