[ Index ] |
PHP Cross Reference of phpBB-3.3.14-deutsch |
[Summary view] [Print] [Text view]
1 <?php 2 /** 3 * 4 * This file is part of the phpBB Forum Software package. 5 * 6 * @copyright (c) phpBB Limited <https://www.phpbb.com> 7 * @license GNU General Public License, version 2 (GPL-2.0) 8 * 9 * For full copyright and license information, please see 10 * the docs/CREDITS.txt file. 11 * 12 */ 13 14 namespace phpbb\db\output_handler; 15 16 class log_wrapper_migrator_output_handler implements migrator_output_handler_interface 17 { 18 /** 19 * Language object. 20 * 21 * @var \phpbb\language\language 22 */ 23 protected $language; 24 25 /** 26 * A migrator output handler 27 * 28 * @var migrator_output_handler_interface 29 */ 30 protected $migrator; 31 32 /** 33 * Log file handle 34 * @var resource 35 */ 36 protected $file_handle = false; 37 38 /** 39 * @var \phpbb\filesystem\filesystem_interface 40 */ 41 protected $filesystem; 42 43 /** 44 * Constructor 45 * 46 * @param \phpbb\language\language $language Language object 47 * @param migrator_output_handler_interface $migrator Migrator output handler 48 * @param string $log_file File to log to 49 * @param \phpbb\filesystem\filesystem_interface $filesystem phpBB filesystem object 50 */ 51 public function __construct(\phpbb\language\language $language, migrator_output_handler_interface $migrator, $log_file, \phpbb\filesystem\filesystem_interface $filesystem) 52 { 53 $this->language = $language; 54 $this->migrator = $migrator; 55 $this->filesystem = $filesystem; 56 $this->file_open($log_file); 57 } 58 59 /** 60 * Open file for logging 61 * 62 * @param string $file File to open 63 */ 64 protected function file_open($file) 65 { 66 if ($this->filesystem->is_writable(dirname($file))) 67 { 68 $this->file_handle = fopen($file, 'w'); 69 } 70 else 71 { 72 throw new \RuntimeException('Unable to write to migrator log file'); 73 } 74 } 75 76 /** 77 * {@inheritdoc} 78 */ 79 public function write($message, $verbosity) 80 { 81 $this->migrator->write($message, $verbosity); 82 83 if ($this->file_handle !== false) 84 { 85 86 $translated_message = $this->language->lang_array(array_shift($message), $message); 87 88 if ($verbosity <= migrator_output_handler_interface::VERBOSITY_NORMAL) 89 { 90 $translated_message = '[INFO] ' . $translated_message; 91 } 92 else 93 { 94 $translated_message = '[DEBUG] ' . $translated_message; 95 } 96 97 fwrite($this->file_handle, $translated_message . "\n"); 98 fflush($this->file_handle); 99 } 100 } 101 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated: Mon Nov 25 19:05:08 2024 | Cross-referenced by PHPXref 0.7.1 |