patch3513_flow3.diff

Patch file for the FLOW3 package - Tim Eilers, 2009-06-01 17:57

Download (4.19 KB)

View differences:

Configuration/Objects.yaml (Arbeitskopie)
137 137
F3\FLOW3\Log\Backend\FileBackend:
138 138
  autowiring: off
139 139
  scope: prototype
140
  properties:
141
    environment: object: F3\FLOW3\Utility\Environment
140 142
F3\FLOW3\Log\Backend\NullBackend:
141 143
  autowiring: off
142 144
  scope: prototype
Configuration/FLOW3.yaml (Arbeitskopie)
39 39
  # Settings for FLOW3's default system logger
40 40
  systemLogger:
41 41
    backend: F3\FLOW3\Log\Backend\FileBackend
42
    backendOptions: { logFileURL: %FLOW3_PATH_DATA%Logs/FLOW3_Production.log }
42
    backendOptions: { CLILogFileURL: %FLOW3_PATH_DATA%Logs/CLI/FLOW3_Production.log , WebLogFileURL: %FLOW3_PATH_DATA%Logs/Web/FLOW3_Production.log }
43 43

  
44 44
locale:
45 45
  
Classes/Log/Backend/FileBackend.php (Arbeitskopie)
48 48
	/**
49 49
	 * @var string
50 50
	 */
51
	protected $logFileURL = '';
51
	protected $CLILogFileURL = '';
52 52

  
53 53
	/**
54
	 * @var string
55
	 */
56
	protected $WebLogFileURL = '';
57

  
58
	/**
54 59
	 * @var resource
55 60
	 */
56 61
	protected $fileHandle;
57 62

  
58 63
	/**
59
	 * Sets URL pointing to the log file. Usually the full directory and
64
	 * @var \F3\FLOW3\Utility\Environment
65
	 */
66
	protected $environment;
67

  
68
	/**
69
	 * Injects the Environment
70
	 *
71
	 * @param \F3\FLOW3\Utility\Environment $environment The environment
72
	 * @return void
73
	 * @author Tim Eilers <tim.eilers AT web.de>
74
	 * @internal
75
	 */
76
	public function injectEnvironment(\F3\FLOW3\Utility\Environment $environment) {
77
		$this->environment = $environment;
78
	}
79

  
80
	/**
81
	 * Sets URL pointing to the log file for CLI requests. Usually the full directory and
60 82
	 * the filename, however any valid stream URL is possible.
61 83
	 *
62 84
	 * @param string $logFileURL URL pointing to the log file
63 85
	 * @return void
64 86
	 * @author Robert Lemke <robert@typo3.org>
65 87
	 */
66
	public function setLogFileURL($logFileURL) {
67
		$this->logFileURL = $logFileURL;
88
	public function setCLILogFileURL($CLILogFileURL) {
89
		$this->CLILogFileURL = $CLILogFileURL;
68 90
	}
69 91

  
70 92
	/**
93
	 * Sets URL pointing to the log file for Webserver requests. Usually the full directory and
94
	 * the filename, however any valid stream URL is possible.
95
	 *
96
	 * @param string $logFileURL URL pointing to the log file
97
	 * @return void
98
	 * @author Robert Lemke <robert@typo3.org>
99
	 */
100
	public function setWebLogFileURL($WebLogFileURL) {
101
		$this->WebLogFileURL = $WebLogFileURL;
102
	}
103

  
104
	/**
71 105
	 * Carries out all actions necessary to prepare the logging backend, such as opening
72 106
	 * the log file or opening a database connection.
73 107
	 *
......
86 120
			\F3\FLOW3\Log\LoggerInterface::SEVERITY_DEBUG     => 'DEBUG    ',
87 121
		);
88 122

  
89
		if (!file_exists($this->logFileURL)) {
90
			$this->fileHandle = fopen($this->logFileURL, 'at');
91
			if ($this->fileHandle === FALSE) throw new \F3\FLOW3\Log\Exception\CouldNotOpenResource('Could not open log file "' . $this->logFileURL . '" for write access.', 1243588980);
123
		if ($this->environment->getSAPIName() === 'cli') {
124
			$logFileURL = $this->CLILogFileURL;
125
		} else {
126
			$logFileURL = $this->WebLogFileURL;
127
		};
92 128

  
93
			$streamMeta = stream_get_meta_data($this->fileHandle);
94
			if ($streamMeta['wrapper_type'] === 'plainfile') {
95
				fclose($this->fileHandle);
96
				chmod($this->logFileURL, 0666);
97
				$this->fileHandle = fopen($this->logFileURL, 'at');
98
			}
99
		} else {
100
			$this->fileHandle = fopen($this->logFileURL, 'at');
101
		}
102
		if ($this->fileHandle === FALSE) throw new \F3\FLOW3\Log\Exception\CouldNotOpenResource('Could not open log file "' . $this->logFileURL . '" for write access.', 1229448440);
129
		$this->fileHandle = fopen($logFileURL, 'at');
130
		if ($this->fileHandle === FALSE) throw new \F3\FLOW3\Log\Exception\CouldNotOpenResource('Could not open log file "' . $logFileURL . '" for write access.', 1229448440);
103 131
	}
104 132

  
105 133
	/**
......
185 213
		return $output;
186 214
	}
187 215
}
188
?>
216
?>