kuthulux / gnome-connection-manager

repository for gnome-connection-manager from kuthulu.com/gcm
Other
66 stars 27 forks source link

Default log directory should not be the homedir #38

Closed jimklimov closed 4 years ago

jimklimov commented 4 years ago

While playing in a newly deployed machine, I found that the session logs are kept (by default) in the home directory, cluttering it quite a bit over time. My usual workstation setting was to keep them in ~/.gcm/logs/ so I never noticed the clumsy default :)

While working on a fix, I also found there were two ways in different places to determine the user's home directory - by os.getenv("HOME") in some places and by os.path.expanduser("~") elsewhere. On one hand, in theory, it could yield different results, and on another it is a bit wasteful to call the routines for every such use so I refactored this into a sanity-checked USERHOME_DIR and further CONFIG_DIR based on that.

There is a potential caveat to this - that the resulting fully qualified path of LOG_PATH is saved by default config, and potentially this is less portable for network-mounted or otherwise shared homedirs that might resolve differently in various OS environments. But this was also the case in original script's use of resolved ~ value. I checked that for portability, a verbatim ~/.gcm/logs2 value can be set manually, is saved, is not mutilated in config by resolving into a particular OS fully qualified path, and is honored (the directory appears and log files in it). The USERHOME_DIR and CONFIG_DIR are not saved into config and are evaluated on a particular operating environment during GCM process startup.

Finally, it seems from dev-testing that the current code does not log the default Local session and has no toggles to configure that. However on my workstation I see a number of local-YYYMMDD-NNN.log files so I wonder how they appeared :) (In tests I did define a separate Servers list connection for a "Local" protocol that can indeed toggle logging - but the default first-opened tab is not logged still). UPDATE1: Since there is just a handful of local-*.log files, I guess I clicked Enable logging in the context menu of running sessions a few times over the past years. So it is not something that happens by default on my workstation. UPDATE2: Added support for local session logging option (off by default, to be as it was - and because it can become a hog of disk space and log file count) and support for appending logs to existing file when we overflow the 999 slots.

jimklimov commented 4 years ago

@kuthulux : gentle bump? :)

kuthulux commented 4 years ago

Hi Jim sorry, i've been quite bussy lately. I just accepted and merge your PR, thanks a lot!!!