fluent / fluent/fluent-logger-python

Formatting message does not work

Aperta
#190 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub
Lingua principale
Python
Stelle
457
Fork
138
Metriche di merge delle PR
Nessuna PR unita negli ultimi 30g

Descrizione

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"}`

Guida per i contributori

Nessuna guida per i contributori indicizzata per questo repository

Valutazione

Questa issue non è ancora stata valutata.

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.