fluent/fluent-logger-python — pull request #18 by EvaSDK (2014-08-01 12:03:07+00:00)
Title: Allow formatter customizations

I am currently pursuing the goal of using fluent just like any other logging Handler/Formatter via `logging.config`

In order to do that I had to solve a couple of problems that make default FluentRecordFormatter not easy to deal with. It is now able to take a format argument which is a dictionary that holds keys and values. Values are regular `LogRecord` standard Python %-style mapping keys. The defaults are unchanged.

I also added a couple of fixes I found in other pull requests as I found them as well during my tests, so this should cover Issue #7, PR #8 and PR #16.

Finally I added a sphinx ready docstring to `FluentRecordFormatter._structuring` although this function could probably be merged in `format` directly since I don't see it used anywhere else.

Once merged, the following sample program:
```
import logging
from fluent.handler import FluentHandler, FluentRecordFormatter

logger = logging.getLogger('toto')
logger.setLevel(logging.DEBUG)
handler = FluentHandler('hello.test')
handler.setLevel(logging.DEBUG)
formatter = FluentRecordFormatter(fmt={
'msg': '%(message)s',
'level': '%(levelname)s',
'hostname': '%(hostname)s',
})
handler.setFormatter(formatter)
logger.addHandler(handler)

logger.info('hel""lo')
```

logs

```
2014-08-01 13:59:05 +0200 hello.test: {"msg":"hel\"\"lo","message":"hel\"\"lo","hostname":"seta.local","level":"INFO"}
```

to fluentd.