Advertisement
ArcaniSGK507

Untitled

Mar 16th, 2025
339
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.64 KB | None | 0 0
  1. <?php
  2.  
  3. declare(strict_types=1);
  4.  
  5. /**
  6.  * Last Hammer Framework 2.0
  7.  * PHP Version 8.3 (Required).
  8.  *
  9.  * @see https://github.com/arcanisgk/LH-Framework
  10.  *
  11.  * @author    Walter Nuñez (arcanisgk/original founder) <icarosnet@gmail.com>
  12.  * @copyright 2017 - 2024
  13.  * @license   http://www.gnu.org/copyleft/lesser.html GNU Lesser General Public License
  14.  * @note      This program is distributed in the hope that it will be useful
  15.  * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
  16.  * or FITNESS FOR A PARTICULAR PURPOSE.
  17.  */
  18.  
  19. namespace Asset\Framework\Core;
  20.  
  21. use Asset\Framework\Trait\SingletonTrait;
  22.  
  23. /**
  24.  * Class EventLog
  25.  * A simple ...
  26.  */
  27. class Log
  28. {
  29.     use SingletonTrait;
  30.  
  31.     public function __construct()
  32.     {
  33.         $this->initLogs();
  34.     }
  35.  
  36.     /**
  37.      * List of logs (TAKE CARE NOT REMOVE IT)
  38.      * error: used when an error occurs caused by: the system itself, the user, the cronjob subsystem, or webservice consumption
  39.      * user: user interaction log (gps navigation or event crud)
  40.      * cronjob: occurs when a cron is executed correctly
  41.      * webservice: occurs when a webservice is consumed correctly
  42.      */
  43.     protected const array LOG_LIST = ['user', 'cron', 'webservice', 'error'];
  44.  
  45.     private function initLogs(): void
  46.     {
  47.         $files     = Files::getInstance();
  48.         $directory = implode(DS, [PD, 'Asset', 'resource', 'log', 'event', '']);
  49.         foreach (self::LOG_LIST as $logDirectory) {
  50.             if (!$files->validateDirectory($directory.$logDirectory)) {
  51.                 $files->createDirectory($directory.$logDirectory);
  52.             }
  53.         }
  54.     }
  55. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement