micropython / micropython/micropython-lib
`logging.FileHandler` not adding new lines to log file
まだ誰も着手していません。
- 主要言語
- Python
- スター
- 2.9k
- フォーク
- 1.1k
- 平均マージ
- 7日 6時間
- マージ済み PR(30日)
- 3
説明
Just tried the updated logging module to replace the StreamHandler and FileHandler adapted from CPython that I was previously using. Thank you @iabdalkader for this update.
StreamHandler works as expected, however I noticed that I wasn't getting any new lines in my log file.
I looked at the previous code and saw that there's a flush after the write in StreamHandler.emit.
Using this subclass for FileHandler, it works like before:
class MyStreamHandler(StreamHandler):
def flush(self):
if self.stream and hasattr(self.stream, "flush"):
self.stream.flush()
def emit(self, record):
super().emit(record)
self.flush()
Is there a reason for not doing a flush in emit, maybe something specific to MicroPython that I'm not aware of?
- MicroPython and board:
MicroPython v1.19.1-915-g2bcd88d55 on 2023-03-02; Raspberry Pi Pico W with RP2040 loggingversion:0.5installed withmip
コントリビューションガイド
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
調査の方向性
まず、報告された MicroPython Raspberry Pi Pico W の環境で更新された logging モジュールを使って問題を再現し、その後 FileHandler を StreamHandler.emit および以前の適応実装と比較します。カスタム flush サブクラスなしで FileHandler のログ出力が期待どおり利用できれば完了です。既存の logging テストがあれば確認してください。
索引モデルが issue の本文から書いたものです。
評価
- 技術スタック
- python
- 領域
- observability
- issue の種類
- バグ
- 難易度
- 2/5
- 見積もり時間
- 1〜3時間
- 活発さ
- 停滞
- 明瞭さ
- おおむね明確
- 初心者へのやさしさ
- 45/100