Skip to content

Logger Does Not Write to File on AdaLogger SD Card #52

@jmangum

Description

@jmangum

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions