Formatting message does not work
Nobody has claimed this yet.
Assessment
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Newbie friendliness
- 48/100
- Issue type
- Bug
- Clarity
- Mostly clear
- Activity status
- Stale
- Tech stack
- python
- Domain
- observability-sre
Research direction
Start at fluent.handler.FluentRecordFormatter and reproduce the supplied logging configuration, comparing its handling of the message field with the other formatted fields. Done means the configured "%(message).5s" value is emitted as five characters in the Fluentd output, with a regression test covering the behavior.
Written by the indexing model from the issue text.
Description
While trying to truncate the message part using formatter. fluent.handler.FluentRecordFormatter works normally with all fields except message
configuration
LOGGING = {
'version': 1,
'disable_existing_loggers': True,
'formatters': {
'verbose': {
'format': "[%(levelname)s %(asctime)s %(module)s -> %(lineno)d] %(message)s",
'datefmt': "%Y-%b-%d %H:%M:%S"
},
'console': {
'format': '[%(levelname)s %(asctime)s] %(message)s',
'datefmt': "%Y-%b-%d %H:%M:%S"
},
'fluent_fmt': {
'()': "fluent.handler.FluentRecordFormatter",
'format': {
'lvl': '%(levelname)s',
'host': '%(hostname)s',
'mod': '%(module)s',
'line': '%(lineno)d',
'tms': '%(created)d',
'trace': '%(exc_text)s',
"proc": '%(processName)s',
"message": "%(message).5s"
}
},
},
'handlers': {
'console': {
'level': 'INFO',
'class': 'logging.StreamHandler',
'formatter': 'verbose'
},
'file': {
'level': 'INFO',
'class': 'logging.handlers.TimedRotatingFileHandler',
'filename': 'celery_nohup',
'when': 'D', # this specifies the interval
'interval': 1, # defaults to 1, only necessary for other values
'formatter': 'verbose',
},
'fluentd': {
'level': 'INFO',
'class': 'fluent.handler.FluentHandler',
'formatter': 'fluent_fmt',
'tag': 'default.log',
'host': 'localhost',
'port': 24224,
'timeout':3.0,
'verbose': False,
"msgpack_kwargs":{'default' : str}
},
},
'loggers': {
'django': {
'handlers': ['console'],
'level': "INFO",
'propagate': True,
},
'celery': {
'handlers': ['console', 'fluentd'],
'level': "INFO",
'propagate': True,
},
'ap_scheduler': {
'handlers': ['console', 'fluentd'],
'level': "INFO",
'propagate': True,
},
},
}
expected output: message truncated to 5 characters
fluentd_1 | 2022-06-02 18:58:43.000000000 +0000 default.log: {"lvl":"INFO","host":"E7440","mod":"mingle","line":"40","tms":"1654196323","trace":"None","proc":"MainProcess","message":"mingl"}
obtained output
fluentd_1 | 2022-06-02 18:58:43.000000000 +0000 default.log: {"lvl":"INFO","host":"E7440","mod":"mingle","line":"40","tms":"1654196323","trace":"None","proc":"MainProcess","message":"mingle: searching for neighbors"}
- Dominant language
- Python
- Stars
- 457
- Forks
- 138
- PR merge metrics
- No merged PRs in 30d
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from fluent/fluent-logger-python
-
support of `asctime` Open
Difficulty 3/5 1-2 days Newbie friendliness 48/100
fluent/fluent-logger-python#210 ·
-
Difficulty 3/5 1-2 days Newbie friendliness 25/100
fluent/fluent-logger-python#196 ·
-
Difficulty 3/5 1-2 days Newbie friendliness 42/100
fluent/fluent-logger-python#195 · 1 comment ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 45/100
fluent/fluent-logger-python#194 ·
-
Difficulty 4/5 3-5 days Newbie friendliness 25/100
fluent/fluent-logger-python#193 · 3 comments ·
All issues in fluent/fluent-logger-python
Similar issues
-
documentation help wanted
Difficulty 2/5 1-3 hours Newbie friendliness 90/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 90/100
simonw/sqlite-utils#872 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100