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

Fails to log silently with specific extra field #85

Open
gnudiff opened this issue May 18, 2018 · 3 comments
Open

Fails to log silently with specific extra field #85

gnudiff opened this issue May 18, 2018 · 3 comments

Comments

@gnudiff
Copy link

gnudiff commented May 18, 2018

If I add extra field named 'status' to the extra fields dict when logging, graypy will drop the message without any error (nothing gets logged).
Example:

import logging
import graypy

mylog=logging.getLogger('order.processing')
handler=graypy.GELFHandler('mylogserver',debugging_fields=True)
mylog.addHandler(handler)
#the following line works
mylog.info("Test123",extra={'fld1':1,'fld2':2})
# the following line doesn't output anything to GrayLog:
mylog.info("Test with status", extra={'fld1':1,'fld2':2, 'status':'OK'})
@severb
Copy link
Owner

severb commented Nov 11, 2018

Do you know why this happens?

@nklapste
Copy link
Collaborator

I'm currently working on another refactoring build nklapste#3 and have worked into testing this issue.

I was unable to create this issue/failure with my tests:

#!/usr/bin/python
# -*- coding: utf-8 -*-

"""pytests for addressing potential issues with adding an ``status`` extra
field withing a given log and having the log failing to appear within graylog.

Related issue:
- Fails to log silently with specific extra field #85

URL:
- https://github.com/severb/graypy/issues/85
"""

import pytest

from tests.integration import LOCAL_GRAYLOG_UP
from tests.integration.helper import get_unique_message, get_graylog_response
from tests.helper import handler, logger


@pytest.mark.skipif(not LOCAL_GRAYLOG_UP,
                    reason="local graylog instance not up")
def test_non_status_field_log(logger):
    message = get_unique_message()
    logger.error(message, extra={"foo": "bar"})
    graylog_response = get_graylog_response(message, fields=["foo"])
    assert message == graylog_response["message"]
    assert "bar" == graylog_response["foo"]


@pytest.mark.skipif(not LOCAL_GRAYLOG_UP,
                    reason="local graylog instance not up")
def test_status_field_issue(logger):
    message = get_unique_message()
    logger.error(message, extra={"status": "OK"})
    graylog_response = get_graylog_response(message, fields=["status"])
    assert message == graylog_response["message"]
    assert "OK" == graylog_response["status"]


@pytest.mark.skipif(not LOCAL_GRAYLOG_UP,
                    reason="local graylog instance not up")
def test_status_field_issue_multi(logger):
    message = get_unique_message()
    logger.error(message, extra={"foo": "bar", "status": "OK"})
    graylog_response = get_graylog_response(message, fields=["foo", "status"])
    assert message == graylog_response["message"]
    assert "bar" == graylog_response["foo"]
    assert "OK" == graylog_response["status"]

Note: these tests are logging to a active graylog docker container.

Possibly when this branch gets finished and (hopefully) merged. This issue will likely be resolved.

@nklapste
Copy link
Collaborator

nklapste commented Mar 19, 2019

@gnudiff does this issue persist with graypy version 1.1.X+?

Currently the implemented test cases in https://github.com/severb/graypy/blob/master/tests/integration/test_status_issue.py seem to validate this issue as resolved as of version 1.1.X+.

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

3 participants