[TYPO3-v4] Harmonizing severity levels
Xavier Perseguers
typo3 at perseguers.ch
Fri Nov 5 15:38:14 CET 2010
Hi,
> However when I look at the list of levels from Log4j or syslogd I feel
> like there are too many levels. It can become very hard to decide which
> level should be used for any given message.
>
>> And I'd like to have a "TRACE" mode because it could be useful when
>> debugging some complicated extensions and not being forced to comment
>> out/remove all those statements when releasing it.
>
> This actually exemplifies what I mentioned above. I generally use "info"
> for that. Is that not good for you? If not, then what do you use "info"
> for? Just curious, we all have our habits.
Well, to be honest I'm never confident with those "lowest" levels :-)
WARNING/ERROR are clear, the others are not good from my point of view.
Example of use of the different levels I see (I use an imaginary __log__
method to have better overview)...
Seems like I provided an example of each of them ;-)
public function foo($param) {
__log__('beginning of foo', TRACE);
foreach (func_get_args() as $arg => $value) {
__log__('argument ' . $arg . ' = ' . $value, TRACE);
}
try {
$content = $this->foo_bar($param);
} catch (InvalidArgumentException $e) {
__log__($e->getMessage(), FATAL);
}
__log__('about to write configuration file', TRACE);
if (!t3lib_div::writeFile('path/to/file', 'some content')) {
__log__('Could not write configuration file', ERROR);
} else {
__log__('Successfully updated configuration file', INFO);
}
__log__('end of foo', TRACE);
}
public function foo_bar($param) {
__log__('beginning of foo_bar', TRACE);
foreach (func_get_args() as $arg => $value) {
__log__('argument ' . $arg . ' = ' . $value, TRACE);
}
if (!is_int($param)) {
throw new InvalidArgumentException('$param must be of type integer',
1234);
}
$toto = external_call();
__log__($toto, DEBUG);
if (!isset($toto['key']) {
// Default to empty content (is not bad but should not occur)
$content = '';
__log__('exernal_call() returned some invalid value', WARNING);
}
$content = $toto['key'][$param];
__log__('end of foo_bar', TRACE);
return $content;
}
More information about the TYPO3-project-v4
mailing list