[gedit-latex] Start cleaning logging. Please use __name__
- From: John Stowers <jstowers src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gedit-latex] Start cleaning logging. Please use __name__
- Date: Thu, 1 Sep 2011 04:29:53 +0000 (UTC)
commit 817b995662effb54aecb35c347a32051b6479fde
Author: John Stowers <john stowers gmail com>
Date: Thu Sep 1 16:28:20 2011 +1200
Start cleaning logging. Please use __name__
latex/__init__.py | 9 +++++++++
latex/base/windowactivatable.py | 29 ++++++++++++++---------------
2 files changed, 23 insertions(+), 15 deletions(-)
---
diff --git a/latex/__init__.py b/latex/__init__.py
index db838af..0577874 100644
--- a/latex/__init__.py
+++ b/latex/__init__.py
@@ -18,12 +18,21 @@
# this program; if not, write to the Free Software Foundation, Inc., 51 Franklin
# Street, Fifth Floor, Boston, MA 02110-1301, USA
+import logging
+
+logging.basicConfig(
+ level=logging.DEBUG,
+ format="%(levelname)-8s:%(name)-30s: %(message)s (l.%(lineno)d)")
+
from gi.repository import Gio
if "org.gnome.gedit.plugins.latex" not in Gio.Settings.list_schemas():
+ logging.critical("Could not find GSettings schema: org.gnome.gedit.plugins.latex")
raise Exception("Plugin schema not installed")
from base.appactivatable import LaTeXAppActivatable
from base.windowactivatable import LaTeXWindowActivatable
+
+
# ex:ts=4:et:
diff --git a/latex/base/windowactivatable.py b/latex/base/windowactivatable.py
index 02ef393..066c7f4 100644
--- a/latex/base/windowactivatable.py
+++ b/latex/base/windowactivatable.py
@@ -22,11 +22,10 @@
This is searched by gedit for a class extending gedit.Plugin
"""
-from gi.repository import Gedit, GObject, Gio, Gtk, PeasGtk
import logging
import string
-logging.basicConfig(level=logging.DEBUG, format="%(asctime)s %(levelname)s %(name)s - %(message)s")
+from gi.repository import Gedit, GObject, Gio, Gtk, PeasGtk
from ..preferences import Preferences
from ..preferences.dialog import PreferencesDialog
@@ -38,6 +37,8 @@ from .resources import Resources
from . import PanelView, WindowContext
from .file import File
+LOG = logging.getLogger(__name__)
+
class LaTeXWindowActivatable(GObject.Object, Gedit.WindowActivatable, PeasGtk.Configurable):
__gtype_name__ = "LaTeXWindowActivatable"
@@ -50,8 +51,6 @@ class LaTeXWindowActivatable(GObject.Object, Gedit.WindowActivatable, PeasGtk.Co
window = GObject.property(type=Gedit.Window)
- _log = logging.getLogger("LaTeXWindowActivatable")
-
# ui definition template for hooking tools in Gedit's ui.
_tool_ui_template = string.Template("""<ui>
<menubar name="MenuBar">
@@ -205,7 +204,7 @@ class LaTeXWindowActivatable(GObject.Object, Gedit.WindowActivatable, PeasGtk.Co
else:
self._toolbar = None
self._toolbar_name = ""
- self._log.info("Toolbar disabled")
+ LOG.info("Toolbar disabled")
def _init_tab_decorators(self):
"""
@@ -222,10 +221,10 @@ class LaTeXWindowActivatable(GObject.Object, Gedit.WindowActivatable, PeasGtk.Co
if view is active_view:
self._active_tab_decorator = decorator
- self._log.debug("_init_tab_decorators: initialized %s decorators" % len(views))
+ LOG.debug("_init_tab_decorators: initialized %s decorators" % len(views))
if len(views) > 0 and not self._active_tab_decorator:
- self._log.warning("_init_tab_decorators: no active decorator found")
+ LOG.warning("_init_tab_decorators: no active decorator found")
def _init_tool_actions(self):
"""
@@ -299,7 +298,7 @@ class LaTeXWindowActivatable(GObject.Object, Gedit.WindowActivatable, PeasGtk.Co
self._toolbar.hide()
def _on_tools_changed(self, tools):
- self._log.debug("_on_tools_changed")
+ LOG.debug("_on_tools_changed")
# remove tool actions and ui
self._ui_manager.remove_ui(self._tool_ui_id)
@@ -332,12 +331,12 @@ class LaTeXWindowActivatable(GObject.Object, Gedit.WindowActivatable, PeasGtk.Co
gfile = Gio.file_new_for_uri(uri)
if Gedit.utils_is_valid_location(gfile):
- self._log.debug("GeditWindow.create_tab_from_uri(%s)" % uri)
+ LOG.debug("GeditWindow.create_tab_from_uri(%s)" % uri)
self.window.create_tab_from_location(
gfile, Gedit.encoding_get_current(),
1, 1, False, True)
else:
- self._log.error("Gedit.utils.uri_is_valid(%s) = False" % uri)
+ LOG.error("Gedit.utils.uri_is_valid(%s) = False" % uri)
def disable(self):
"""
@@ -369,7 +368,7 @@ class LaTeXWindowActivatable(GObject.Object, Gedit.WindowActivatable, PeasGtk.Co
extension = tab_decorator.extension
- self._log.debug("---------- ADJUST: %s" % (extension))
+ LOG.debug("---------- ADJUST: %s" % (extension))
latex_extensions = self._preferences.get("latex-extensions").split(",")
@@ -469,10 +468,10 @@ class LaTeXWindowActivatable(GObject.Object, Gedit.WindowActivatable, PeasGtk.Co
@param window: Gedit.Window object
@param tab: Gedit.Tab object
"""
- self._log.debug("tab_added")
+ LOG.debug("tab_added")
if tab in self._tab_decorators:
- self._log.warning("There is already a decorator for tab %s" % tab)
+ LOG.warning("There is already a decorator for tab %s" % tab)
return
self._create_tab_decorator(tab)
@@ -484,7 +483,7 @@ class LaTeXWindowActivatable(GObject.Object, Gedit.WindowActivatable, PeasGtk.Co
@param window: GeditWindow
@param tab: the closed GeditTab
"""
- self._log.debug("tab_removed")
+ LOG.debug("tab_removed")
# As we don't call GeditWindowDecorator.adjust() if the new
# tab is not the active one (for example, when opening several
@@ -512,7 +511,7 @@ class LaTeXWindowActivatable(GObject.Object, Gedit.WindowActivatable, PeasGtk.Co
@param window: the GeditWindow
@param tab: the activated GeditTab
"""
- self._log.debug("active_tab_changed")
+ LOG.debug("active_tab_changed")
if tab in self._tab_decorators.keys():
decorator = self._tab_decorators[tab]
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]