deftinc / feature_gate

MIT License
0 stars 2 forks source link

Fixes `No such file or directory: 'logs/development.log'` issue #9

Closed prontsevychev closed 3 months ago

prontsevychev commented 3 months ago

In certain environments we've run into issues with proper permissions to write logs. This normalizes logs to be set relative to PROJECT_ROOT environment variable. If that is not available it falls back to the current working directory.

vinbarnes commented 3 months ago

@Fl1p92 Thanks for adding the change so logs directory is relative to PROJECT_ROOT. However, since this library should be project agnostic, how about if we have the fallback default value be "." ?

prontsevychev commented 3 months ago

@vinbarnes Python doesn't work properly with relative paths because python process (uWSGI as we saw yesterday) can be run from weird places. So better to use absolute path, that's why for default I choose '/srv', but we can change it to whatever you want. Also, to be more "agnostic", we probably need to pass project root dir environment variable (or actual path) through client initialization as one of arguments like Client(PosthogAdapter(api_key=posthog_api_key, project_id=posthog_project_id, project_root_path='/path/to/ur/project'))

prontsevychev commented 3 months ago

P.S. Add some linter, 2 spaces indentation in the code breaks my heart :heart_on_fire:

vinbarnes commented 3 months ago

@Fl1p92 not sure what I did with this PR to not have the commits show up here. But a comparison of the changes I added to yours https://github.com/deftinc/feature_gate/compare/main...bugfix/fix-logs-issue

First, the safest thing to do is default to current working directory when PROJECT_ROOT is not available. cdf83b795bd88eed719c1f3dc081ab836ca10756 Second, I took your suggestion and ensured to use the absolute path. b791cfdec14304ed94cd25dd898f7095051c7176

prontsevychev commented 3 months ago

@vinbarnes I'm not a contributor to your repo, so I can't create branch here directly, so I forked your repo to my GitHub and opened PR from my branch. Now I have synced the fork, and your commits have been added to PR.

vinbarnes commented 3 months ago

Now I have synced the fork, and your commits have been added to PR.

Thanks!

prontsevychev commented 3 months ago

@rick @thephw Can you please reveiw this PR to speed up its merge?