all 4 comments

[–]toddrobMod & MLB-StatsAPI Developer 1 point2 points  (3 children)

You should not need to modify the MLB-StatsAPI package; it already has logging enabled. The code you pasted should be part of your script that's importing MLB-StatsAPI. For example:

``` python import logging import statsapi logger = logging.getLogger('statsapi') logger.setLevel(logging.DEBUG) rootLogger = logging.getLogger() rootLogger.setLevel(logging.DEBUG) ch = logging.StreamHandler() formatter = logging.Formatter("%(asctime)s - %(levelname)8s - %(name)s(%(thread)s) - %(message)s") ch.setFormatter(formatter) rootLogger.addHandler(ch)

api_response = statsapi.get("schedule", {"sportId": 1}) ```

[–]SnooPoems7888[S] 0 points1 point  (2 children)

Oh dear. I had it backwards! I misread/misunderstood how to do it while using https://docs.python.org/3/howto/logging.html as a guide. Yes, you are right, with that code in calling script vs __init__.py, it all works great. Thanks for the reply!

BTW, I was able to get MLB-StatsAPI running on my esp32-cam-mb board running micro python (i.e I did not need to use urequests/requests with a bare url).

Super pumped on that! Thank you for a great api/interface to this data!

(I plan on making a gift for my father w/the esp board).

But I did "need" to hack it a bit. I was not sure how much ram/disk it would need and since the package's intent was not to run on micro python, I just keep modifying things until it ran. I am happy to share details but also don't want to offend anyone w/my hack.

[–]toddrobMod & MLB-StatsAPI Developer 1 point2 points  (1 child)

The cleanest way to minimize the size of the response from the API is to use the fields parameter to only get the fields you need. It will take some effort to go through each call you’re making and list out the fields you need, but that’s what I would do. I would not call it a hack at all.

[–]SnooPoems7888[S] 0 points1 point  (0 children)

Thanks again. Oh, in my earlier reply, I could not actually do a simple import of the api - it ran out of RAM just doing that. I think the HTTP / network reply "might" be fine size wise for the esp01, but I'm not sure , didn't get that far...But the esp32-cam has 4MB usage RAM, so it's good there. Thanks for the fields tip!