Commit 13078dfd authored by Philipp Hörist's avatar Philipp Hörist

Delete debug logs older than 3 days

parent 6424a64a
Pipeline #3986 passed with stages
in 2 minutes and 35 seconds
......@@ -33,6 +33,7 @@
# You should have received a copy of the GNU General Public License
# along with Gajim. If not, see <http://www.gnu.org/licenses/>.
import time
import sys
from datetime import datetime
from pathlib import Path
......@@ -359,6 +360,7 @@ class GajimApplication(Gtk.Application):
if app.get_debug_mode():
# Redirect has to happen before logging init
self._cleanup_debug_logs()
self._redirect_output()
logging_helpers.init()
logging_helpers.set_verbose()
......@@ -393,11 +395,21 @@ class GajimApplication(Gtk.Application):
@staticmethod
def _redirect_output():
debug_folder = Path(configpaths.get('DEBUG'))
date = datetime.today().strftime('%Y-%m-%d')
date = datetime.today().strftime('%d%m%Y-%H%M%S')
filename = '%s-debug.log' % date
fd = open(debug_folder / filename, 'a')
sys.stderr = sys.stdout = fd
@staticmethod
def _cleanup_debug_logs():
debug_folder = Path(configpaths.get('DEBUG'))
debug_files = list(debug_folder.glob('*-debug.log*'))
now = time.time()
for file in debug_files:
# Delete everything older than 3 days
if file.stat().st_ctime < now - 259200:
file.unlink()
def add_actions(self):
''' Build Application Actions '''
from gajim import app_actions
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment