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

Support RFC 5424 timestamp #38

Open
ypid-geberit opened this issue Feb 5, 2019 · 2 comments
Open

Support RFC 5424 timestamp #38

ypid-geberit opened this issue Feb 5, 2019 · 2 comments

Comments

@ypid-geberit
Copy link

Would you be open to supporting a timestamp format as specified by RFC 5424 (section 6.2.3) for readability? I know that this is not specified by GELF 1.1 so I would suggest to make it configurable using a timestamp_format='rfc-3339' parameter.

Related standards: ISO 8601, RFC 3339.

Ref: severb/graypy#99

@keeprocking
Copy link
Owner

Sure, will give it a look.

@ypid-geberit
Copy link
Author

There was a workaround discussed in severb/graypy#99

The same works for pygelf as well:

import logging
import datetime

from pygelf import GelfTcpHandler


class RFC3339TimestampFilter(logging.Filter):
    def filter(self, record):
        record.timestamp = datetime.datetime.fromtimestamp(record.created, datetime.timezone.utc).astimezone().isoformat()
        return True


logger = logging.getLogger()
logger.addHandler(GelfTcpHandler(host='127.0.0.1', port=9401, include_extra_fields=True))
logger.addFilter(RFC3339TimestampFilter())

logger.error('hello gelf')

You may close this issue if you like.

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

2 participants