[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Commit-gnuradio] [gnuradio] 87/101: grc: refactor: Added logging
From: |
git |
Subject: |
[Commit-gnuradio] [gnuradio] 87/101: grc: refactor: Added logging |
Date: |
Thu, 16 Mar 2017 14:58:13 +0000 (UTC) |
This is an automated email from the git hooks/post-receive script.
jcorgan pushed a commit to branch python3
in repository gnuradio.
commit ba675b38ad095dba6fa15af04b158ca04667fa8b
Author: Seth Hitefield <address@hidden>
Date: Thu Sep 22 14:58:31 2016 -0400
grc: refactor: Added logging
---
grc/gui/Application.py | 8 ++++++++
grc/gui/MainWindow.py | 5 +++++
grc/main.py | 32 +++++++++++++++++++++++++++++++-
3 files changed, 44 insertions(+), 1 deletion(-)
diff --git a/grc/gui/Application.py b/grc/gui/Application.py
index c68b38b..5c643ea 100644
--- a/grc/gui/Application.py
+++ b/grc/gui/Application.py
@@ -22,6 +22,7 @@ from __future__ import absolute_import, print_function
import os
import subprocess
+import logging
from gi.repository import Gtk, GObject
@@ -33,6 +34,9 @@ from .PropsDialog import PropsDialog
from ..core import ParseXML, Messages
+log = logging.getLogger(__name__)
+
+
class Application(Gtk.Application):
"""
The action handler will setup all the major window components,
@@ -57,15 +61,19 @@ class Application(Gtk.Application):
self.platform = platform
self.config = platform.config
+ log.debug("__init__()")
+
#initialize
self.init_file_paths = [os.path.abspath(file_path) for file_path in
file_paths]
self.init = False
def do_startup(self):
Gtk.Application.do_startup(self)
+ log.debug("do_startup()")
def do_activate(self):
Gtk.Application.do_activate(self)
+ log.debug("do_activate()")
self.main_window = MainWindow(self, self.platform, self._handle_action)
self.main_window.connect('delete-event', self._quit)
diff --git a/grc/gui/MainWindow.py b/grc/gui/MainWindow.py
index c371601..5bb4c52 100644
--- a/grc/gui/MainWindow.py
+++ b/grc/gui/MainWindow.py
@@ -20,6 +20,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301, USA
from __future__ import absolute_import
import os
+import logging
from gi.repository import Gtk, Gdk, GObject
@@ -34,6 +35,9 @@ from .Notebook import Notebook, Page
from ..core import Messages
+log = logging.getLogger(__name__)
+
+
############################################################
# Main window
############################################################
@@ -51,6 +55,7 @@ class MainWindow(Gtk.ApplicationWindow):
Setup the menu, toolbar, flow graph editor notebook, block selection
window...
"""
Gtk.ApplicationWindow.__init__(self, title="GNU Radio Companion",
application=app)
+ log.debug("__init__()")
self._platform = platform
self.config = platform.config
diff --git a/grc/main.py b/grc/main.py
index e0f2b26..305e8b8 100755
--- a/grc/main.py
+++ b/grc/main.py
@@ -15,7 +15,7 @@
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
USA
-import argparse, sys
+import argparse, logging, sys
import gi
gi.require_version('Gtk', '3.0')
@@ -35,11 +35,20 @@ GRC comes with ABSOLUTELY NO WARRANTY.
This is free software, and you are welcome to redistribute it.
"""
+LOG_LEVELS = {
+ 'debug': logging.DEBUG,
+ 'info': logging.INFO,
+ 'warning': logging.WARNING,
+ 'error': logging.ERROR,
+ 'critical': logging.CRITICAL,
+}
+
def main():
parser = argparse.ArgumentParser(
description=VERSION_AND_DISCLAIMER_TEMPLATE % gr.version())
parser.add_argument('flow_graphs', nargs='*')
+ parser.add_argument('--log', choices=['debug', 'info', 'warning', 'error',
'critical'], default='warning')
args = parser.parse_args()
try:
@@ -47,6 +56,25 @@ def main():
except:
pass
+ # Enable logging
+ # Note: All other modules need to use the 'grc.<module>' convention
+ log = logging.getLogger('grc')
+ log.setLevel(logging.DEBUG)
+
+ # Console formatting
+ console = logging.StreamHandler()
+ console.setLevel(LOG_LEVELS[args.log])
+
+ msg_format = '[%(asctime)s - %(levelname)8s] --- %(message)s
(%(filename)s:%(lineno)s)'
+ date_format = '%I:%M'
+ formatter = logging.Formatter(msg_format, datefmt=date_format)
+
+ #formatter = utils.log.ConsoleFormatter()
+ console.setFormatter(formatter)
+ log.addHandler(console)
+
+ log.debug("Loading platform")
+
platform = Platform(
version=gr.version(),
version_parts=(gr.major_version(), gr.api_version(),
gr.minor_version()),
@@ -54,5 +82,7 @@ def main():
install_prefix=gr.prefix()
)
+ log.debug("Loading application")
app = Application(args.flow_graphs, platform)
+ log.debug("Running")
sys.exit(app.run())
- [Commit-gnuradio] [gnuradio] 86/101: grc: gtk3: Renamed the ActionHandler to Application, (continued)
- [Commit-gnuradio] [gnuradio] 86/101: grc: gtk3: Renamed the ActionHandler to Application, git, 2017/03/16
- [Commit-gnuradio] [gnuradio] 58/101: grc: gtk3: fix bug in mouse motion handling, git, 2017/03/16
- [Commit-gnuradio] [gnuradio] 51/101: grc: gtk3: fix port label hiding, git, 2017/03/16
- [Commit-gnuradio] [gnuradio] 59/101: grc: gtk3: fix drag and drop from block tree, git, 2017/03/16
- [Commit-gnuradio] [gnuradio] 30/101: grc: refactor: selected blocks handling, git, 2017/03/16
- [Commit-gnuradio] [gnuradio] 74/101: grc: gtk3: minor gui flowgraph cleanup, git, 2017/03/16
- [Commit-gnuradio] [gnuradio] 93/101: grc: gtk3: python3 error, some cmake fixes, git, 2017/03/16
- [Commit-gnuradio] [gnuradio] 85/101: grc: refactor: Moved the notebook and console into separate classes., git, 2017/03/16
- [Commit-gnuradio] [gnuradio] 61/101: grc: gtk3: draw ports before blocks and simplyfied draw code, git, 2017/03/16
- [Commit-gnuradio] [gnuradio] 80/101: grc: gtk3: fix MessageDialog for Variable Panel config, git, 2017/03/16
- [Commit-gnuradio] [gnuradio] 87/101: grc: refactor: Added logging,
git <=
- [Commit-gnuradio] [gnuradio] 77/101: grc: gtk3: make screnshots as png, pdf and svg, git, 2017/03/16
- [Commit-gnuradio] [gnuradio] 81/101: grc: refactor: make gr.prefs() optional (for testing), git, 2017/03/16
- [Commit-gnuradio] [gnuradio] 99/101: grc: gtk3: update cmake requirements, git, 2017/03/16
- [Commit-gnuradio] [gnuradio] 92/101: grc: gtk3: fix block layout sizes when zooming, git, 2017/03/16
- [Commit-gnuradio] [gnuradio] 94/101: grc: gtk3: reimplemented custom bg colors for param entry boxes, git, 2017/03/16
- [Commit-gnuradio] [gnuradio] 98/101: cmake: add DIRECTORY support to GR_PYTHON_INSTALL and use it for grc, git, 2017/03/16
- [Commit-gnuradio] [gnuradio] 11/101: grc: py3k compat using python-modernize, git, 2017/03/16
- [Commit-gnuradio] [gnuradio] 75/101: grc: gtk3: rewrite file dialogs and support multiple extentions for screenshots, git, 2017/03/16
- [Commit-gnuradio] [gnuradio] 70/101: grc: gtk3: fancier coloring for disabled and bypassed blocks, git, 2017/03/16
- [Commit-gnuradio] [gnuradio] 83/101: grc: refactor: Cleaned up imports, git, 2017/03/16