Mercurial > libervia-web
diff browser_side/panels.py @ 439:d52f529a6d42
browser side: use of new log system (first draft):
- configuration is hardcoded in libervia.py, it will change in the (hopefuly) near future
- log level is DEBUG for the moment, will be changed to INFO when configuration will not be hardcoded anymore
- the basic log backend is used, in the future, a console.debug/info/etc should be used instead. A log widget which HTML colors is also an option
author | Goffi <goffi@goffi.org> |
---|---|
date | Thu, 08 May 2014 17:21:34 +0200 |
parents | bbdbee25123a |
children | 17259c2ff96f |
line wrap: on
line diff
--- a/browser_side/panels.py Thu May 08 17:21:30 2014 +0200 +++ b/browser_side/panels.py Thu May 08 17:21:34 2014 +0200 @@ -18,6 +18,8 @@ # along with this program. If not, see <http://www.gnu.org/licenses/>. import pyjd # this is dummy in pyjs +from sat.core.log import getLogger +log = getLogger(__name__) from pyjamas.ui.SimplePanel import SimplePanel from pyjamas.ui.AbsolutePanel import AbsolutePanel from pyjamas.ui.VerticalPanel import VerticalPanel @@ -187,7 +189,7 @@ try: self.getCompletionItems().completions.remove(key) except KeyError: - print "WARNING: trying to remove an unknown key" + log.warning("trying to remove an unknown key") def _getTarget(self, txt): """ Say who will receive the messsage @@ -227,7 +229,7 @@ msg = MicroblogPanel.warning_msg_group % group target_hook = (txt[_end + 2:], group) else: - print "ERROR: Unknown target" + log.error("Unknown target") target_hook, _type, msg = getSelectedOrStatus() return (target_hook, _type, msg) @@ -317,7 +319,7 @@ if type_ == "NONE": return if not msg: - print "WARNING: no msg set uniBox warning" + log.warning("no msg set uniBox warning") return if type_ == "PUBLIC": style = "targetPublic" @@ -328,7 +330,7 @@ elif type_ == "ONE2ONE": style = "targetOne2One" else: - print "ERROR: unknown message type" + log.error("unknown message type") return contents = HTML(msg) @@ -585,7 +587,7 @@ } entry = self._blog_panel.addEntry(data) if entry is None: - print "The entry of id %s can not be commented" % self.id + log.info("The entry of id %s can not be commented" % self.id) return entry._parent_entry = self self._current_comment = entry @@ -733,7 +735,7 @@ @return: a couple (type, msg) for calling self.host.showWarning""" if comment is None: # composing from the unibox if self.selected_entry and not self.selected_entry.comments: - print ("ERROR: an item without comment is selected") + log.error("an item without comment is selected") return ("NONE", None) comment = self.selected_entry is not None if comment: @@ -773,12 +775,12 @@ """Insert several microblogs at once @param mblogs: dictionary of microblogs, as the result of getMassiveLastGroupBlogs """ - print "Massive insertion of %d microblogs" % len(mblogs) + log.debug("Massive insertion of %d microblogs" % len(mblogs)) for publisher in mblogs: - print "adding blogs for [%s]" % publisher + log.debug("adding blogs for [%s]" % publisher) for mblog in mblogs[publisher]: if not "content" in mblog: - print ("WARNING: No content found in microblog [%s]", mblog) + log.warning("No content found in microblog [%s]", mblog) continue self.addEntry(mblog) @@ -788,7 +790,7 @@ """ for mblog in mblogs: if not "content" in mblog: - print ("WARNING: No content found in microblog [%s]", mblog) + log.warning("No content found in microblog [%s]", mblog) continue self.addEntry(mblog) @@ -897,7 +899,7 @@ try: self.vpanel.getParent().ensureVisible(entry) # scroll to the clicked entry except AttributeError: - print "FIXME: MicroblogPanel.vpanel should be wrapped in a ScrollPanel!" + log.warning("FIXME: MicroblogPanel.vpanel should be wrapped in a ScrollPanel!") removeStyle = lambda entry: entry.removeStyleName('selected_entry') if not self.host.uni_box or not entry.comments: entry.addStyleName('selected_entry') # blink the clicked entry @@ -912,7 +914,7 @@ if self.selected_entry: removeStyle(self.selected_entry) if entry: - print "microblog entry selected (author=%s)" % entry.author + log.debug("microblog entry selected (author=%s)" % entry.author) entry.addStyleName('selected_entry') self.selected_entry = entry @@ -1064,7 +1066,7 @@ self.type = type_ self.nick = None if not target: - print "ERROR: Empty target !" + log.error("Empty target !") return self.target = target self.__body = AbsolutePanel() @@ -1236,7 +1238,7 @@ attr = "%s_panel" % attr if hasattr(self, attr): return - print ("%s Game Started \o/" % game_type) + log.info("%s Game Started \o/" % game_type) panel = classes[game_type](self, referee, self.nick, players, *args) setattr(self, attr, panel) self.vpanel.insert(panel, 0)