fbs-tutorial icon indicating copy to clipboard operation
fbs-tutorial copied to clipboard

Guidance for Properly Logging

Open j9ac9k opened this issue 6 years ago • 1 comments

It would be good if the tutorial provided some guidance on how to setup logging, especially for macOS, where the logger FileHandler only takes relative paths, and thus attempts to write in a read-only portion of the app bundle.

On Linux, the logging.handlers.FileHandler appeared to work fine (wrote to the user home directory if I remember right), I have not tested on Windows.

Thanks for the awesome package!

j9ac9k avatar Aug 14 '19 17:08 j9ac9k

Thank you for the suggestion. I want to keep fbs's docs to the minimum, because the longer they get, the more difficult they become to read (by fbs users like yourself), and to maintain for me. I feel like the logging questions you describe are beyond the scope of fbs's documentation, as this isn't strictly a feature of fbs.

Having said that, I don't think FileHandler only takes relative paths. Without having tested it, I think you should be able to log to the home directory with the following code on all OSs:

from os import makedirs
from os.path import expanduser
from logging import FileHandler
makedirs(expanduser('~/.myapp'), exist_ok=True)
handler = FileHandler(expanduser('~/.myapp/myapp.log'))

Hope this helps.

mherrmann avatar Aug 16 '19 07:08 mherrmann