1234567891011121314151617181920212223242526272829303132333435 |
- <?php
- namespace Core\Log;
- class FileLog extends AnyLog
- {
- const DATA_SEPARATOR = ' | ';
- const ERROR = 'ERROR';
- const INFO = 'INFO';
- const DATA = 'DATA';
- public static function write($message, $type)
- {
- $lineArray[] = date('Y-m-d H:i:s');
- $lineArray[] = $type;
- $lineArray[] = trim($message);
- $lineArray[] = "\n";
-
- $file = 'logs/file-' . ((isset($_GET['shop'])) ? str_replace(SHOPIFY_DOMAIN, '', $_GET['shop']): '') . '.log';
- // if (!file_exists($file)) {
- // touch($file);
- // }
- file_put_contents($file, implode(self::DATA_SEPARATOR, $lineArray), FILE_APPEND);
- }
- public static function getFile()
- {
- $file = 'logs/file-' . ((isset($_GET['shop'])) ? str_replace(SHOPIFY_DOMAIN, '', $_GET['shop']): '') . '.log';
- return $file;
- }
- }
|