thekid/rfc — Issue #125: RFC 0125: Fluent interface for util.log.LogCategory
Author: thekid
Created: 2011-10-09 15:15:48+00:00
State: open
Labels: rfc

Scope of Change
====
A method util.log.LogCategory::withAppender() method will added. It works
just like addAppender() but returns the category itself instead of the
added appender.

Rationale
====
Fluent interface.

Functionality
====

Current functionality
----

```php
getCategory($traceable->getClassName());
$cat->addAppender(new SmtpAppender('errors@example.com'), LOGGER_FLAG_ERROR);
$cat->addAppender(new FileAppender('/var/log/xp/debug.log'));

$traceable->setTrace($cat);
?>
```

Fluent interface example
----

```php
setTrace(Logger::getInstance()->getCategory($traceable->getClassName())
->withAppender(new SmtpAppender('errors@example.com'), LOGGER_FLAG_ERROR)
->withAppender(new FileAppender('/var/log/xp/debug.log'))
);
?>
```

Security considerations
====
n/a

Speed impact
====
One new method in LogAppender() class, almost not noticeable.

Dependencies
====
n/a

Related documents
====
- http://xp-framework.net/rfc/contrib/rfc0125.diff
Implementing patch

Comments
====
n/a