Verzeichnisstruktur phpBB-3.3.15


Veröffentlicht
28.08.2024

So funktioniert es


Auf das letzte Element klicken. Dies geht jeweils ein Schritt zurück

Auf das Icon klicken, dies öffnet das Verzeichnis. Nochmal klicken schließt das Verzeichnis.
Auf den Verzeichnisnamen klicken, dies zeigt nur das Verzeichnis mit Inhalt an

(Beispiel Datei-Icons)

Auf das Icon klicken um den Quellcode anzuzeigen

log_wrapper_migrator_output_handler.php

Zuletzt modifiziert: 02.04.2025, 15:02 - Dateigröße: 2.23 KiB


001  <?php
002  /**
003  *
004  * This file is part of the phpBB Forum Software package.
005  *
006  * @copyright (c) phpBB Limited <https://www.phpbb.com>
007  * @license GNU General Public License, version 2 (GPL-2.0)
008  *
009  * For full copyright and license information, please see
010  * the docs/CREDITS.txt file.
011  *
012  */
013   
014  namespace phpbb\db\output_handler;
015   
016  class log_wrapper_migrator_output_handler implements migrator_output_handler_interface
017  {
018      /**
019       * Language object.
020       *
021       * @var \phpbb\language\language
022       */
023      protected $language;
024   
025      /**
026       * A migrator output handler
027       *
028       * @var migrator_output_handler_interface
029       */
030      protected $migrator;
031   
032      /**
033       * Log file handle
034       * @var resource
035       */
036      protected $file_handle = false;
037   
038      /**
039       * @var \phpbb\filesystem\filesystem_interface
040       */
041      protected $filesystem;
042   
043      /**
044       * Constructor
045       *
046       * @param \phpbb\language\language                    $language    Language object
047       * @param migrator_output_handler_interface            $migrator    Migrator output handler
048       * @param string                                    $log_file    File to log to
049       * @param \phpbb\filesystem\filesystem_interface    $filesystem    phpBB filesystem object
050       */
051      public function __construct(\phpbb\language\language $language, migrator_output_handler_interface $migrator, $log_file, \phpbb\filesystem\filesystem_interface $filesystem)
052      {
053          $this->language = $language;
054          $this->migrator = $migrator;
055          $this->filesystem = $filesystem;
056          $this->file_open($log_file);
057      }
058   
059      /**
060       * Open file for logging
061       *
062       * @param string $file File to open
063       */
064      protected function file_open($file)
065      {
066          if ($this->filesystem->is_writable(dirname($file)))
067          {
068              $this->file_handle = fopen($file, 'w');
069          }
070          else
071          {
072              throw new \RuntimeException('Unable to write to migrator log file');
073          }
074      }
075   
076      /**
077       * {@inheritdoc}
078       */
079      public function write($message, $verbosity)
080      {
081          $this->migrator->write($message, $verbosity);
082   
083          if ($this->file_handle !== false)
084          {
085   
086              $translated_message = $this->language->lang_array(array_shift($message), $message);
087   
088              if ($verbosity <= migrator_output_handler_interface::VERBOSITY_NORMAL)
089              {
090                  $translated_message = '[INFO] ' . $translated_message;
091              }
092              else
093              {
094                  $translated_message = '[DEBUG] ' . $translated_message;
095              }
096   
097              fwrite($this->file_handle, $translated_message . "\n");
098              fflush($this->file_handle);
099          }
100      }
101  }
102