Skip to content
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

Implement Configuration and Log dirs classes #61

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

richibrics
Copy link
Owner

PR that simplifies the selection of directories based on

  • env variable
  • os based direcotry
  • script folder

The GetDirectory class must be extended and the subclasses only have to specify the methods to retrieve

  • macOS path
  • windows path
  • Linux path

and two variables

  • the name for the env variable
  • the name for the subfolder that will be used if the selected method is the "script folder" one

Reimplemented Configurations path selection with the new class and implemented the same for Logs

@richibrics
Copy link
Owner Author

Now I need to find Logs folders for Windows and Linux.

On macOS now it works correctly and Logs can be found also from the Console app.

@richibrics richibrics linked an issue Feb 22, 2023 that may be closed by this pull request
@infeeeee
Copy link
Collaborator

On Linux:

There is no standard in the XDG spec for logs, I would place it in $XDG_CACHE_HOME, and fallback to $HOME/.cache, as the first answer recommends it here: https://superuser.com/questions/1293842/where-should-userspecific-application-log-files-be-stored-in-gnu-linux

But logging to file on Linux nowadays is not really important. A continuously running process like this should be managed by systemd, which has a robust logging system called journald, and it records everything sent to stdout. But there are still some distros not using systemd, for them this should be useful.

On Windows:

I have seen other programs simply log into %appdata%. A bit more elegant solution would be to %localappdata%. The difference is if roaming profiles enabled in a company network, content from %appdata% should be copied with the user, while %localappdata% stays on the machine. Roaming profiles are not enabled even on most companies (at least I've never seen a working one) so this doesn't really matter most of the times.

@richibrics
Copy link
Owner Author

Great, thank you for the explanations !

Comment on lines +28 to +31
return os.path.join(os.environ["XDG_CACHE_HOME"], "Logs")
else:
return os.path.join(os.environ["HOME"], ".cache", "Logs")
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if "XDG_CACHE_HOME" in os.environ:
return os.path.join(os.environ["XDG_CACHE_HOME"], "Logs")
else:
return os.path.join(os.environ["HOME"], ".cache", "Logs")
if "XDG_CACHE_HOME" in os.environ:
return os.path.join(os.environ["XDG_CACHE_HOME"], "IoTuring", "Logs")
else:
return os.path.join(os.environ["HOME"], ".cache", "IoTuring", "Logs")

These folders don't exist by default

# get the folder on windows where to store application log file
def _windowsFolderPath(self):
# return joined local app data folder and "Logs" subfolder
return os.path.join(os.environ["LOCALAPPDATA"], "Logs")
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
return os.path.join(os.environ["LOCALAPPDATA"], "Logs")
return os.path.join(os.environ["LOCALAPPDATA"], "IoTuring", "Logs")

Here as well, create a separate folder for IoTuring

@richibrics richibrics added enhancement New feature or request stale WIP and removed WIP labels Nov 27, 2023
@infeeeee infeeeee mentioned this pull request Jan 14, 2024
5 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request stale
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Change folder for Logs like we did for configurations
2 participants