beatsabertools / sabergen

Beat Saber song generator
GNU General Public License v3.0
3 stars 0 forks source link

Figure out how to log from the library #12

Closed ryanwersal closed 6 years ago

ryanwersal commented 6 years ago

11 adds a FIXME surrounding how best to communicate failures or even successes from within the library. I ran into this as I had various shenanigans with getting ffmpeg setup successfully and I had to add the print statements.

From a brief search, I can see that Python has a logging module that seems like it would do the trick. Ideally we would require the caller of the library to provide us a logger to use (if None is provided we can error or just log nothing - I'm leaning towards failing since we should require a logger). The CLI and webapp and other consumers could then handle logging concerns themselves.

zvekovius commented 6 years ago

Maybe I'm alone, but we should probably return errors in a consistent way and let the calling folks care about how it is handled, I don't think logging is the answer to that at the library level? The CLI should be able to show things to the user without much cruft. the web app should be able to decide if it just writes to a server log, or in dev/debug mode it spits stderr to the webpage.

My vote is for a list of standard exceptions that we expect, a catchall for the scenarios we don't follow. Return all of them to the caller and the caller determine how to log/show this to the user? Maybe I'm off base on my perception of logging or the general idea.


EDIT: We had a high bandwidth convo about this. I misunderstood the level that logging went down to in the request. I took it as the lib should create filez, instead of letting the calling application decide. After re-reading the original issue, idk how I read it that way. Whatever, reading is hard. I'm +1 for this and using python logger.

ryanwersal commented 6 years ago

I agree with errors but what about more verbose information about the internals of the library? As a concrete example: how do we expose stdout for ffmpeg to the library consumer?