From 53168a6015909b69480efeadee71a099a2e5dc31 Mon Sep 17 00:00:00 2001
From: guinux <nuxgui@gmail.com>
Date: Sun, 24 Feb 2013 14:37:54 +0100
Subject: [PATCH] write now transactions in /var/log/pamac.log file

---
 pamac/common.py       |  6 ++++++
 pamac/pamac-daemon.py | 12 ++++++++++++
 2 files changed, 18 insertions(+)

diff --git a/pamac/common.py b/pamac/common.py
index 73957bc7..4cc0089e 100644
--- a/pamac/common.py
+++ b/pamac/common.py
@@ -33,3 +33,9 @@ def write_pid_file():
 def rm_pid_file():
 	if isfile(pid_file):
 		remove(pid_file)
+
+import time
+
+def write_log_file(string):
+	with open('/var/log/pamac.log', 'a') as logfile:
+		logfile.write(time.strftime('[%Y-%m-%d %H:%M]') + ' {}\n'.format(string))
diff --git a/pamac/pamac-daemon.py b/pamac/pamac-daemon.py
index f7382333..454af548 100644
--- a/pamac/pamac-daemon.py
+++ b/pamac/pamac-daemon.py
@@ -63,12 +63,24 @@ class PamacDBusService(dbus.service.Object):
 		elif ID is 9:
 			self.action = 'Installing...'
 			self.icon = '/usr/share/pamac/icons/24x24/status/package-add.png'
+		elif ID is 10:
+			formatted_event = 'Installed {} ({})'.format(tupel[0].name, tupel[0].version)
+			common.write_log_file(formatted_event)
+			print(formatted_event)
 		elif ID is 11:
 			self.action = 'Removing...'
 			self.icon = '/usr/share/pamac/icons/24x24/status/package-delete.png'
+		elif ID is 12:
+			formatted_event = 'Removed {} ({})'.format(tupel[0].name, tupel[0].version)
+			common.write_log_file(formatted_event)
+			print(formatted_event)
 		elif ID is 13:
 			self.action = 'Upgrading...'
 			self.icon = '/usr/share/pamac/icons/24x24/status/package-update.png'
+		elif ID is 14:
+			formatted_event = 'Upgraded {} ({} -> {})'.format(tupel[1].name, tupel[1].version, tupel[0].version)
+			common.write_log_file(formatted_event)
+			print(formatted_event)
 		elif ID is 15:
 			self.action = 'Checking integrity...'
 			self.icon = '/usr/share/pamac/icons/24x24/status/package-search.png'
-- 
GitLab