adafruit / adafruit/Adafruit_CircuitPython_Logging
Logger Does Not Write to File on AdaLogger SD Card
- Dominant language
- Python
- Stars
- 15
- Forks
- 23
- PR merge metrics
- No merged PRs in 30d
Description
Trying to use `adafruit_logging` to write logs to an SD card on an AdaLogger mounted to a RP Pico W. Writing to SD card works (using `csvwriter` or simply using `file.write`), but `adafruit_logging` does not. Tried the following simple test:
```
# Debug CP logging 2023/10/07
import board
import sdcardio
import busio
import digitalio
import storage
import adafruit_logging as logging
#
# SPI SD_CS pin
SD_CS = board.GP17
# SPI setup for SD card
spi = busio.SPI(board.GP18, board.GP19, board.GP16)
sdcard = sdcardio.SDCard(spi, SD_CS)
vfs = storage.VfsFat(sdcard)
try:
storage.mount(vfs, "/sd")
print("\nSD card mounted")
#l.info('\nSD card mounted')
except ValueError:
print("No SD card")
#l.error('No SD card')
# Setup log handler
l = logging.getLogger('sdfile')
l.addHandler(logging.FileHandler('/sd/log.txt'))
l.setLevel(logging.DEBUG)
l.debug('debug')
with open("/sd/log.txt", "a") as f:
f.write("Hello world!\r\n")
```
I believe that this should have resulted in a `Hello world!` message then a `debug` message being written to the `log.txt` file. The only message written to the `log.txt` file was the `Hello world!` message.
Board has Circuit Python 8.2.4 installed.
Contributor guide
No contributing guide indexed for this repository
Research direction
Start with the reproduction in issue #52 on CircuitPython 8.2.4, focusing on logging.FileHandler('/sd/log.txt') and the subsequent l.debug('debug') call. Compare its result with the direct open('/sd/log.txt', 'a') write; done means the debug message is appended to the SD-card log file.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- observability-sre
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100