[gnome-music/wip/mschraal/glib-logging: 64/65] Remove old logger



commit cde8c9e2e5ca4f04114e501ce91c815d4cb8473b
Author: Marinus Schraal <mschraal gnome org>
Date:   Sat Feb 1 16:08:35 2020 +0100

    Remove old logger

 gnome-music.in         | 27 -------------------
 gnomemusic/__init__.py | 73 --------------------------------------------------
 2 files changed, 100 deletions(-)
---
diff --git a/gnome-music.in b/gnome-music.in
index fe0de970..7ee9498e 100755
--- a/gnome-music.in
+++ b/gnome-music.in
@@ -23,10 +23,8 @@
 # code, but you are not obligated to do so.  If you do not wish to do so,
 # delete this exception statement from your version.
 
-import argparse
 import gettext
 import locale
-import logging
 import os
 import signal
 import sys
@@ -54,10 +52,6 @@ Gst.init(None)
 LOCALE_DIR = '@localedir@'
 PKGDATA_DIR = '@pkgdatadir@'
 
-# Log settings
-LOG_FORMAT = '%(asctime)s %(levelname)s\t%(message)s'
-LOG_DATE_FORMAT = '%H:%M:%S'
-
 
 def set_libgd():
     """Configures application to run our own libgd copy."""
@@ -93,26 +87,6 @@ def set_exception_hook():
     old_hook = sys.excepthook
     sys.excepthook = new_hook
 
-
-def set_log_level():
-    """Sets application log level according to debug value."""
-    parser = argparse.ArgumentParser()
-    parser.add_argument('-d', '--debug', action='store_true',
-                        default=False, dest='debug')
-    args = parser.parse_args()
-    if args.debug:
-        logging.basicConfig(level=logging.DEBUG, format=LOG_FORMAT,
-                            datefmt=LOG_DATE_FORMAT)
-        # Gtk hates "-d" switch, so lets drop it
-        if '-d' in sys.argv:
-            sys.argv.remove('-d')
-        if '--debug' in sys.argv:
-            sys.argv.remove('--debug')
-    else:
-        logging.basicConfig(level=logging.WARN, format=LOG_FORMAT,
-                            datefmt=LOG_DATE_FORMAT)
-
-
 def set_internationalization():
     """Sets application internationalization."""
     locale.bindtextdomain('@application_id@', LOCALE_DIR)
@@ -142,7 +116,6 @@ def main():
     set_libgd()
     set_gfm()
     set_exception_hook()
-    set_log_level()
     set_internationalization()
     set_resources()
     return run_application()
diff --git a/gnomemusic/__init__.py b/gnomemusic/__init__.py
index d25af2f6..e69de29b 100644
--- a/gnomemusic/__init__.py
+++ b/gnomemusic/__init__.py
@@ -1,73 +0,0 @@
-# Copyright (c) 2013 Vadim Rutkovsky <vrutkovs redhat com>
-# Copyright (c) 2013 Guillaume Quintard <guillaume quintard gmail com>
-# Copyright (c) 2013 Eslam Mostafa <cseslam gmail com>
-# Copyright (c) 2013 Manish Sinha <manishsinha ubuntu com>
-#
-# GNOME Music is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 2 of the License, or
-# (at your option) any later version.
-#
-# GNOME Music is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License along
-# with GNOME Music; if not, write to the Free Software Foundation, Inc.,
-# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
-#
-# The GNOME Music authors hereby grant permission for non-GPL compatible
-# GStreamer plugins to be used and distributed together with GStreamer
-# and GNOME Music.  This permission is above and beyond the permissions
-# granted by the GPL license by which GNOME Music is covered.  If you
-# modify this code, you may extend this exception to your version of the
-# code, but you are not obligated to do so.  If you do not wish to do so,
-# delete this exception statement from your version.
-
-from itertools import chain
-from time import time
-import logging
-
-logger = logging.getLogger(__name__)
-tabbing = 0
-
-
-def log(fn):
-    """Decorator to log function details.
-
-    Shows function signature, return value, time elapsed, etc.
-    Logging will be done if the debug flag is set.
-    :param fn: the function to be decorated
-    :return: function wrapped for logging
-    """
-    if logger.getEffectiveLevel() > logging.DEBUG:
-        return fn
-
-    def wrapped(*v, **k):
-        global tabbing
-        name = fn.__qualname__
-        filename = fn.__code__.co_filename.split('/')[-1]
-        lineno = fn.__code__.co_firstlineno
-
-        params = ", ".join(map(repr, chain(v, k.values())))
-
-        if 'rateLimitedFunction' not in name:
-            logger.debug("%s%s(%s)[%s:%s]", '|' * tabbing, name, params,
-                         filename, lineno)
-        tabbing += 1
-        start = time()
-        retval = fn(*v, **k)
-        elapsed = time() - start
-        tabbing -= 1
-        elapsed_time = ''
-        if elapsed > 0.1:
-            elapsed_time = ', took %02f' % elapsed
-        if (elapsed_time
-                or retval is not None):
-            if 'rateLimitedFunction' not in name:
-                logger.debug("%s  returned %s%s", '|' * tabbing, repr(retval),
-                             elapsed_time)
-        return retval
-
-    return wrapped


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]