mirror of
https://github.com/getnamingo/registry.git
synced 2025-08-05 09:11:29 +02:00
Added Monolog for automation scripts
This commit is contained in:
parent
e609b3f84d
commit
9d5078270a
13 changed files with 203 additions and 121 deletions
|
@ -5,12 +5,15 @@ require_once 'helpers.php';
|
|||
|
||||
// Connect to the database
|
||||
$dsn = "{$c['db_type']}:host={$c['db_host']};dbname={$c['db_database']};port={$c['db_port']}";
|
||||
$logFilePath = '/var/log/namingo/send_invoice.log';
|
||||
$log = setupLogger($logFilePath, 'Invoice_Generator');
|
||||
$log->info('job started.');
|
||||
|
||||
try {
|
||||
$pdo = new PDO($dsn, $c['db_username'], $c['db_password']);
|
||||
$pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
|
||||
} catch (PDOException $e) {
|
||||
die("Connection failed: " . $e->getMessage());
|
||||
$log->error('DB Connection failed: ' . $e->getMessage());
|
||||
}
|
||||
|
||||
$previous = date("Y-m", strtotime("first day of previous month"));
|
||||
|
@ -110,15 +113,14 @@ try {
|
|||
$response = curl_exec($curl);
|
||||
|
||||
if ($response === false) {
|
||||
throw new Exception(curl_error($curl), curl_errno($curl));
|
||||
$log->error('Curl error: ' . curl_error($curl) . curl_errno($curl));
|
||||
}
|
||||
|
||||
curl_close($curl);
|
||||
|
||||
print_r($response);
|
||||
$log->info('job finished successfully.');
|
||||
}
|
||||
}
|
||||
} catch (PDOException $e) {
|
||||
// Handle any PDO exceptions here
|
||||
echo "Database error: " . $e->getMessage();
|
||||
$log->error('Database error: ' . $e->getMessage());
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue