From 2678d78812f8e6fa4a2fdf068ac2ef9242ea5530 Mon Sep 17 00:00:00 2001 From: Kiooeht Date: Thu, 12 May 2011 13:09:30 -0700 Subject: [PATCH] Options for logging time stamps --- TODO.mkdn | 1 + menus.py | 14 ++++++++++++-- pesterchum.py | 45 +++++++++++++++++++++++++++++++++------------ 3 files changed, 46 insertions(+), 14 deletions(-) diff --git a/TODO.mkdn b/TODO.mkdn index 9c5df52..779b9bb 100644 --- a/TODO.mkdn +++ b/TODO.mkdn @@ -18,6 +18,7 @@ Bugs * Issues with connecting? Client not closing connection right? People keep getting "nick taken" messages * Windows XP SP2: sometimes mouse clicks dont register? must be some kinda crash * When using mood sort, scroll position jumps to last selected chum +* When switching chumhandles, OP doesn't appear to retain OP status (though they do) Mac Bugs -------- diff --git a/menus.py b/menus.py index 1e3216f..d135386 100644 --- a/menus.py +++ b/menus.py @@ -696,9 +696,17 @@ class PesterOptions(QtGui.QDialog): layout_3.addWidget(self.sortBox, 10) self.logpesterscheck = QtGui.QCheckBox("Log all Pesters", self) - self.logpesterscheck.setChecked(self.config.logPesters()) + if self.config.logPesters() & self.config.LOG: + self.logpesterscheck.setChecked(True) self.logmemoscheck = QtGui.QCheckBox("Log all Memos", self) - self.logmemoscheck.setChecked(self.config.logMemos()) + if self.config.logMemos() & self.config.LOG: + self.logmemoscheck.setChecked(True) + self.stamppestercheck = QtGui.QCheckBox("Log Time Stamps for Pesters", self) + if self.config.logPesters() & self.config.STAMP: + self.stamppestercheck.setChecked(True) + self.stampmemocheck = QtGui.QCheckBox("Log Time Stamps for Memos", self) + if self.config.logMemos() & self.config.STAMP: + self.stampmemocheck.setChecked(True) self.idleBox = QtGui.QSpinBox(self) self.idleBox.setStyleSheet("background:#FFFFFF") @@ -798,6 +806,8 @@ class PesterOptions(QtGui.QDialog): layout_logs.setAlignment(QtCore.Qt.AlignTop) layout_logs.addWidget(self.logpesterscheck) layout_logs.addWidget(self.logmemoscheck) + layout_logs.addWidget(self.stamppestercheck) + layout_logs.addWidget(self.stampmemocheck) self.pages.addWidget(widget) # Idle diff --git a/pesterchum.py b/pesterchum.py index 2efa808..3df8f37 100644 --- a/pesterchum.py +++ b/pesterchum.py @@ -88,18 +88,28 @@ class PesterLog(object): self.logpath = _datadir+"logs" def log(self, handle, msg): - if handle[0] == '#': - if not self.parent.config.logMemos(): return + if self.parent.config.time12Format(): + time = strftime("[%I:%M") else: - if not self.parent.config.logPesters(): return + time = strftime("[%H:%M") + if self.parent.config.showSeconds(): + time += strftime(":%S] ") + else: + time += "] " + if handle[0] == '#': + if not self.parent.config.logMemos() & self.parent.config.LOG: return + if not self.parent.config.logMemos() & self.parent.config.STAMP: + time = "" + else: + if not self.parent.config.logPesters() & self.parent.config.LOG: return + if not self.parent.config.logPesters() & self.parent.config.STAMP: + time = "" if str(handle).upper() == "NICKSERV": return #watch out for illegal characters handle = re.sub(r'[<>:"/\\|?*]', "_", handle) - #time = strftime("[%H:%M:%S] ") - # no time codes in logs - bbcodemsg = convertTags(msg, "bbcode") - html = convertTags(msg, "html")+"
" - msg = convertTags(msg, "text") + bbcodemsg = time + convertTags(msg, "bbcode") + html = time + convertTags(msg, "html")+"
" + msg = time +convertTags(msg, "text") modes = {"bbcode": bbcodemsg, "html": html, "text": msg} if not self.convos.has_key(handle): time = datetime.now().strftime("%Y-%m-%d.%H.%M") @@ -267,6 +277,9 @@ class pesterTheme(dict): class userConfig(object): def __init__(self, parent): self.parent = parent + # Use for bit flag log setting + self.LOG = 1 + self.STAMP = 2 if sys.platform != "darwin": self.filename = "pesterchum.js" else: @@ -345,9 +358,9 @@ class userConfig(object): self.set("onlineNumbers", False) return self.config.get('onlineNumbers', False) def logPesters(self): - return self.config.get('logPesters', True) + return self.config.get('logPesters', self.LOG | self.STAMP) def logMemos(self): - return self.config.get('logMemos', True) + return self.config.get('logMemos', self.LOG) def disableUserLinks(self): return not self.config.get('userLinks', True) def idleTime(self): @@ -2414,11 +2427,19 @@ class PesterWindow(MovingWindow): self.chumList.hideOnlineNumbers() self.config.set("onlineNumbers", onlinenumsetting) # logging - logpesterssetting = self.optionmenu.logpesterscheck.isChecked() + logpesterssetting = 0 + if self.optionmenu.logpesterscheck.isChecked(): + logpesterssetting = logpesterssetting | self.config.LOG + if self.optionmenu.stamppestercheck.isChecked(): + logpesterssetting = logpesterssetting | self.config.STAMP curlogpesters = self.config.logPesters() if logpesterssetting != curlogpesters: self.config.set('logPesters', logpesterssetting) - logmemossetting = self.optionmenu.logmemoscheck.isChecked() + logmemossetting = 0 + if self.optionmenu.logmemoscheck.isChecked(): + logmemossetting = logmemossetting | self.config.LOG + if self.optionmenu.stampmemocheck.isChecked(): + logmemossetting = logmemossetting | self.config.STAMP curlogmemos = self.config.logMemos() if logmemossetting != curlogmemos: self.config.set('logMemos', logmemossetting)