logging tweaks
This commit is contained in:
parent
982f298fc4
commit
88fb8458c1
|
@ -4,9 +4,9 @@
|
||||||
|
|
||||||
from __future__ import absolute_import, division, print_function, unicode_literals
|
from __future__ import absolute_import, division, print_function, unicode_literals
|
||||||
|
|
||||||
import logging
|
from logging import getLogger, DEBUG as _DEBUG
|
||||||
_DEBUG = logging.DEBUG
|
_log = getLogger('solaar.ui.window')
|
||||||
_log = logging.getLogger('solaar.ui.window')
|
del getLogger
|
||||||
|
|
||||||
from gi.repository import Gtk, Gdk, GLib
|
from gi.repository import Gtk, Gdk, GLib
|
||||||
|
|
||||||
|
|
|
@ -8,7 +8,10 @@ from __future__ import absolute_import, division, print_function, unicode_litera
|
||||||
try:
|
try:
|
||||||
# this import is allowed to fail, in which case the entire feature is unavailable
|
# this import is allowed to fail, in which case the entire feature is unavailable
|
||||||
from gi.repository import Notify
|
from gi.repository import Notify
|
||||||
import logging
|
|
||||||
|
from logging import getLogger, DEBUG as _DEBUG
|
||||||
|
_log = getLogger('solaar.ui.notify')
|
||||||
|
del getLogger
|
||||||
|
|
||||||
from solaar import NAME
|
from solaar import NAME
|
||||||
from . import icons as _icons
|
from . import icons as _icons
|
||||||
|
@ -25,18 +28,18 @@ try:
|
||||||
global available
|
global available
|
||||||
if available:
|
if available:
|
||||||
if not Notify.is_initted():
|
if not Notify.is_initted():
|
||||||
logging.info("starting desktop notifications")
|
_log.info("starting desktop notifications")
|
||||||
try:
|
try:
|
||||||
return Notify.init(NAME)
|
return Notify.init(NAME)
|
||||||
except:
|
except:
|
||||||
logging.exception("initializing desktop notifications")
|
_log.exception("initializing desktop notifications")
|
||||||
available = False
|
available = False
|
||||||
return available and Notify.is_initted()
|
return available and Notify.is_initted()
|
||||||
|
|
||||||
|
|
||||||
def uninit():
|
def uninit():
|
||||||
if available and Notify.is_initted():
|
if available and Notify.is_initted():
|
||||||
logging.info("stopping desktop notifications")
|
_log.info("stopping desktop notifications")
|
||||||
_notifications.clear()
|
_notifications.clear()
|
||||||
Notify.uninit()
|
Notify.uninit()
|
||||||
|
|
||||||
|
@ -67,10 +70,11 @@ try:
|
||||||
n.set_urgency(Notify.Urgency.NORMAL)
|
n.set_urgency(Notify.Urgency.NORMAL)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
# logging.debug("showing %s", n)
|
if _log.isEnabledFor(_DEBUG):
|
||||||
|
_log.debug("showing %s", n)
|
||||||
n.show()
|
n.show()
|
||||||
except Exception:
|
except Exception:
|
||||||
logging.exception("showing %s", n)
|
_log.exception("showing %s", n)
|
||||||
|
|
||||||
|
|
||||||
def show(dev, reason=None, icon=None):
|
def show(dev, reason=None, icon=None):
|
||||||
|
@ -96,10 +100,11 @@ try:
|
||||||
n.set_urgency(urgency)
|
n.set_urgency(urgency)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
# logging.debug("showing %s", n)
|
if _log.isEnabledFor(_DEBUG):
|
||||||
|
_log.debug("showing %s", n)
|
||||||
n.show()
|
n.show()
|
||||||
except Exception:
|
except Exception:
|
||||||
logging.exception("showing %s", n)
|
_log.exception("showing %s", n)
|
||||||
|
|
||||||
except ImportError:
|
except ImportError:
|
||||||
available = False
|
available = False
|
||||||
|
|
|
@ -171,7 +171,7 @@ def _add_device(icon, device):
|
||||||
device_info = (device.receiver.serial, device.serial, device.name, device.number, device.status)
|
device_info = (device.receiver.serial, device.serial, device.name, device.number, device.status)
|
||||||
icon._devices_info.insert(index, device_info)
|
icon._devices_info.insert(index, device_info)
|
||||||
|
|
||||||
print ("status_icon: added", index, ":", device_info)
|
# print ("status_icon: added", index, ":", device_info)
|
||||||
|
|
||||||
menu_item = Gtk.ImageMenuItem.new_with_label(' ' + device.name)
|
menu_item = Gtk.ImageMenuItem.new_with_label(' ' + device.name)
|
||||||
icon._menu.insert(menu_item, index)
|
icon._menu.insert(menu_item, index)
|
||||||
|
|
Loading…
Reference in New Issue