Formatting message does not work

オープン
#190 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

評価

難易度
3/5
見積もり時間
1〜2日
初心者へのやさしさ
48/100
issue の種類
バグ
明瞭さ
おおむね明確
活発さ
停滞
技術スタック
python

調査の方向性

fluent.handler.FluentRecordFormatter から始め、提供された logging 設定を再現し、message フィールドの処理を他のフォーマット済みフィールドと比較します。設定された "%(message).5s" の値が Fluentd の出力で 5 文字として出力され、この動作をカバーする回帰テストがあることをもって完了とします。

索引モデルが issue の本文から書いたものです。

説明

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

主要言語
Python
スター
457
フォーク
138
PR マージ指標
30日以内にマージされた PR はありません

コントリビューションガイド

このリポジトリのコントリビューションガイドは索引されていません

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

fluent/fluent-logger-python のほかの issue

fluent/fluent-logger-python の issue をすべて見る

似ている issue

Python の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。