Uh oh!
There was an error while loading. Please reload this page.
Allow formatter customizations - #18
Conversation
kdeldycke
commented
Aug 1, 2014
👍 |
EvaSDK
commented
Aug 1, 2014
A sample configuration would be: logging:
version: 1formatters:
brief:
format: '%(message)s'default:
format: '%(asctime)s %(levelname)-8s %(name)-15s %(message)s'datefmt: '%Y-%m-%d %H:%M:%S'fluent_fmt:
'()': fluent.handler.FluentRecordFormatterformat:
message: '%(message)s'level: '%(levelname)s'hostname: '%(hostname)s'where: '%(module)s.%(funcName)s'handlers:
console:
class : logging.StreamHandlerlevel: DEBUGformatter: defaultstream: ext://sys.stdoutfluent:
class: fluent.handler.FluentHandlerhost: localhostport: 24224tag: test.loggingformatter: fluent_fmtlevel: DEBUGnull:
class: logging.NullHandlerloggers:
amqp:
handlers: [null]propagate: Falseconf:
handlers: [null]propagate: False'': # root loggerhandlers: [console, fluent]level: DEBUGpropagate: Falseloaded likeso: importlogging.configimportyamlwithopen('logging.yaml') asfd:
conf=yaml.load(fd)
logging.config.dictConfig(conf['logging'])the way to customize formatter via logging.config.dictConfig drove me a bit crazy until I found the proper documentation. So I figured it would be useful to add it as an example here. |
5082d68 to
fbd05d8CompareEvaSDK
commented
Feb 3, 2015
Branch updated against 0.3.5. |
kiyoto
commented
Feb 3, 2015
The idea looks good to me. Do you think you can add a test for the string input case? After that it's ready to be merged. |
EvaSDK
commented
Feb 4, 2015
I can look into it yes. |
fbd05d8 to
2768952CompareEvaSDK
commented
Feb 25, 2015
Added some tests and fixed a few issues while doing so. The most annoying thing to me is the drop of python 2.6 support due to class changes in python logging module and how it handles the asctime attribute. I think dropping 2.6 support is not too bad anyway due to it being unsupported on most distributions nowadays. If you still want to support it, I can elaborate an alternative solution. |
Should solve concerns from issue fluent#7.
For consistency's sake.
This does not work in python2.6 as it did not use usesTime to detect the presence of asctime in fmt.
2768952 to
70d68cbCompareEvaSDK
commented
May 27, 2015
Added py26 compatibility back. It does not look pretty but if you want it for older distributions, you have it. This fixes: issue #7, PR #8, PR #22 / issue #23 With PR #31, this adds up to 3 pull requests to fix conformance to logging classes. Please tell me what to do with this PR, it has been almost a year and I did everything I could to satisfy your modification requests. |
repeatedly
commented
May 27, 2015
yyuu
commented
May 29, 2015
Looks good to me. |
repeatedly
commented
May 30, 2015
@yyuu Feel free to merge this PR and release new version. Maybe update minor version is better? |
EvaSDK
commented
May 30, 2015
The PR contains a version bump to 0.4.0 as I felt this was an important enough change. |
repeatedly
commented
May 31, 2015
How about this PR? > #31 |
yyuu
commented
Jun 1, 2015
@repeatedly I don't have permission to upload fluent-logger to PyPI.... |
EvaSDK
commented
Jun 1, 2015
#31 squashed all my commits in one and adds a feature that is debatable on its own. Imho, it should be reworked as a single commit on top of my branch first. |
There was a problem hiding this comment.
@EvaSDK Why did you remove 2.6 from .travis.yml? It's still in tox.ini and seems working fine at least for me.
There was a problem hiding this comment.
Looks like I forgot to update .travis.yml when I re-added support for it. I'll fix that.
EvaSDK
commented
Jun 3, 2015
w00t, thanks. |
I am currently pursuing the goal of using fluent just like any other logging Handler/Formatter via
logging.configIn 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
LogRecordstandard 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._structuringalthough this function could probably be merged informatdirectly since I don't see it used anywhere else.Once merged, the following sample program:
logs
to fluentd.