micropython / micropython/micropython-lib
`logging.FileHandler` not adding new lines to log file
Nessuno ha ancora preso questa issue.
- Lingua principale
- Python
- Stelle
- 2.9k
- Fork
- 1.1k
- Merge medio
- 7g 6h
- PR unite (30g)
- 3
Descrizione
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
Guida per i contributori
Apri la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Direzione di ricerca
Inizia riproducendo il problema con il modulo di logging aggiornato sulla configurazione MicroPython Raspberry Pi Pico W segnalata, quindi confronta FileHandler con StreamHandler.emit e con la precedente implementazione adattata. Il lavoro è completo quando l’output dei log di FileHandler è disponibile come previsto senza la sottoclasse personalizzata di flush; controlla i test di logging esistenti, se presenti.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Valutazione
- Stack tecnologico
- python
- Ambito
- observability
- Tipo di issue
- Bug
- Difficoltà
- 2/5
- Tempo stimato
- 1-3 ore
- Stato di attività
- Ferma
- Chiarezza
- Abbastanza chiara
- Idoneità per principianti
- 45/100