Add newsletter management functionality

This commit is contained in:
Alex Cabal 2022-03-20 17:40:19 -05:00
parent 90ee0a93c9
commit b0197d189a
57 changed files with 1017 additions and 143 deletions

View file

@ -3,18 +3,27 @@ use function Safe\fopen;
use function Safe\fwrite;
use function Safe\fclose;
use function Safe\error_log;
use function Safe\gmdate;
class Logger{
public static function WritePostmarkWebhookLogEntry(string $requestId, string $text): void{
self::WriteLogEntry(POSTMARK_WEBHOOK_LOG_FILE_PATH, $requestId . "\t" . $text);
}
public static function WriteGithubWebhookLogEntry(string $requestId, string $text): void{
self::WriteLogEntry(GITHUB_WEBHOOK_LOG_FILE_PATH, $requestId . "\t" . $text);
}
public static function WriteLogEntry(string $file, string $text): void{
try{
$fp = fopen(GITHUB_WEBHOOK_LOG_FILE_PATH, 'a+');
$fp = fopen($file, 'a+');
}
catch(\Exception $ex){
self::WriteErrorLogEntry('Couldn\'t open log file: ' . GITHUB_WEBHOOK_LOG_FILE_PATH . '. Exception: ' . vds($ex));
self::WriteErrorLogEntry('Couldn\'t open log file: ' . $file . '. Exception: ' . vds($ex));
return;
}
fwrite($fp, gmdate('Y-m-d H:i:s') . "\t" . $requestId . "\t" . $text . "\n");
fwrite($fp, gmdate('Y-m-d H:i:s') . "\t" . $text . "\n");
fclose($fp);
}