Skip to content

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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
jmangum opened this issue Oct 7, 2023 · 0 comments
Open

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

jmangum opened this issue Oct 7, 2023 · 0 comments

Comments

@jmangum
Copy link

jmangum commented Oct 7, 2023

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant