Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug] Log message formatted with %r raises BulkIndexError #62

Open
popes01a opened this issue Jun 7, 2019 · 0 comments
Open

[Bug] Log message formatted with %r raises BulkIndexError #62

popes01a opened this issue Jun 7, 2019 · 0 comments

Comments

@popes01a
Copy link

popes01a commented Jun 7, 2019

I have recently switched to using CMRESHandler and I encoutered some issues when trying to use %r for string formatting.

The handler is set up as below:

handler = {
    'level': 'INFO',
    'class': 'cmreslogging.handlers.CMRESHandler',
    'hosts': [{'host': ELASTICSEARCH_HOST, 'port': ELASTICSEARCH_PORT}],
    'es_index_name': 'app-name',
    'raise_on_indexing_exceptions': True,
}

Assuming I have the following dictionary to log:

parameters = { 
    'month': datetime.datetime(2018, 12, 1, 0, 0, tzinfo=tzutc()), 
    'status': 'complete', 
}

If I do logger.info('Parameters: %r' % parameters) then nothing gets logged and I get the following error:

raise BulkIndexError('%i document(s) failed to index.' % len(errors), errors)

'error': {
	'type': 'mapper_parsing_exception',
	'reason': 'failed to parse field [args] of type [text]',
	'caused_by': {'type': 'illegal_state_exception', 'reason': "Can't get text on a START_OBJECT at 1:610"}
}

I switched to logger.info('Parameters: %s' % repr(parameters)) and that works fine, however it would be nice to be able to use %r and avoid wrapping parameters in repr().

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant