[master] Whenever storage code tries to log a method call, do so into the 'tmp/storage.log' file. (a part of #524980)

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

 



Previously, the method call was logged into 'tmp/anaconda.log' which
made the file harder to do anything useful with.
---
 anaconda                     |    5 ++++-
 iutil.py                     |   16 ----------------
 storage/devices.py           |    5 ++---
 storage/devicetree.py        |    2 +-
 storage/formats/__init__.py  |    3 ++-
 storage/formats/disklabel.py |    2 +-
 storage/formats/dmraid.py    |    2 +-
 storage/formats/fs.py        |    4 +---
 storage/formats/luks.py      |    2 +-
 storage/formats/lvmpv.py     |    2 +-
 storage/formats/mdraid.py    |    2 +-
 storage/formats/multipath.py |    2 +-
 storage/formats/swap.py      |    3 ++-
 storage/storage_log.py       |   20 +++++++++++++++++---
 14 files changed, 35 insertions(+), 35 deletions(-)

diff --git a/anaconda b/anaconda
index 55eaf8d..3734741 100755
--- a/anaconda
+++ b/anaconda
@@ -310,7 +310,9 @@ def setupEnvironment():
 
 def setupLoggingFromOpts(opts):
     if opts.loglevel and logLevelMap.has_key(opts.loglevel):
-        log.setHandlersLevel(logLevelMap[opts.loglevel])
+        level = logLevelMap[opts.loglevel]
+        log.setHandlersLevel(level)
+        storage.storage_log.logger.setHandlersLevel(level)
 
     if opts.syslog:
         if opts.syslog.find(":") != -1:
@@ -603,6 +605,7 @@ if __name__ == "__main__":
     import vnc
     import users
     import kickstart
+    import storage.storage_log
     from flags import flags
 
     # the following makes me very sad. -- katzj
diff --git a/iutil.py b/iutil.py
index 82a8f9a..18df7df 100644
--- a/iutil.py
+++ b/iutil.py
@@ -25,7 +25,6 @@ import os, string, stat, sys
 import signal
 import os.path
 from errno import *
-import inspect
 import warnings
 import subprocess
 from flags import flags
@@ -808,21 +807,6 @@ def get_sysfs_path_by_name(dev_name, class_name="block"):
     if os.path.exists(dev_path):
         return dev_path
 
-def log_method_call(d, *args, **kwargs):
-    classname = d.__class__.__name__
-    methodname = inspect.stack()[1][3]
-    fmt = "%s.%s:"
-    fmt_args = [classname, methodname]
-    for arg in args:
-        fmt += " %s ;"
-        fmt_args.append(arg)
-
-    for k, v in kwargs.items():
-        fmt += " %s: %s ;"
-        fmt_args.extend([k, v])
-
-    log.debug(fmt % tuple(fmt_args))
-
 def numeric_type(num):
     """ Verify that a value is given as a numeric data type.
 
diff --git a/storage/devices.py b/storage/devices.py
index 7f30d32..c10417c 100644
--- a/storage/devices.py
+++ b/storage/devices.py
@@ -108,7 +108,8 @@ import platform
 import block
 
 from errors import *
-from iutil import log_method_call, notify_kernel, numeric_type
+from iutil import notify_kernel, numeric_type
+from storage.storage_log import log_method_call
 from udev import *
 from formats import get_device_format_class, getFormat, DeviceFormat
 from isys import compareDrives
@@ -3217,5 +3218,3 @@ class NFSDevice(StorageDevice, NetworkStorageDevice):
     def destroy(self):
         """ Destroy the device. """
         log_method_call(self, self.name, status=self.status)
-
-
diff --git a/storage/devicetree.py b/storage/devicetree.py
index 650ef96..7dc4867 100644
--- a/storage/devicetree.py
+++ b/storage/devicetree.py
@@ -35,7 +35,7 @@ import devicelibs.mdraid
 import devicelibs.dm
 import devicelibs.lvm
 from udev import *
-from iutil import log_method_call
+from storage.storage_log import log_method_call
 
 import gettext
 _ = lambda x: gettext.ldgettext("anaconda", x)
diff --git a/storage/formats/__init__.py b/storage/formats/__init__.py
index ab33211..0af9d8f 100644
--- a/storage/formats/__init__.py
+++ b/storage/formats/__init__.py
@@ -22,7 +22,8 @@
 
 import os
 
-from iutil import notify_kernel, get_sysfs_path_by_name, log_method_call
+from iutil import notify_kernel, get_sysfs_path_by_name
+from storage.storage_log import log_method_call
 from ..errors import *
 from ..devicelibs.dm import dm_node_from_name
 
diff --git a/storage/formats/disklabel.py b/storage/formats/disklabel.py
index faf04f4..c567e00 100644
--- a/storage/formats/disklabel.py
+++ b/storage/formats/disklabel.py
@@ -23,7 +23,7 @@
 import os
 import copy
 
-from iutil import log_method_call
+from storage.storage_log import log_method_call
 import parted
 import _ped
 import platform
diff --git a/storage/formats/dmraid.py b/storage/formats/dmraid.py
index 5bdb7f6..7d93700 100644
--- a/storage/formats/dmraid.py
+++ b/storage/formats/dmraid.py
@@ -20,7 +20,7 @@
 # Red Hat Author(s): Dave Lehman <dlehman@xxxxxxxxxx>
 #
 
-from iutil import log_method_call
+from storage.storage_log import log_method_call
 from flags import flags
 from ..errors import *
 from . import DeviceFormat, register_device_format
diff --git a/storage/formats/fs.py b/storage/formats/fs.py
index 63a116b..2287a1f 100644
--- a/storage/formats/fs.py
+++ b/storage/formats/fs.py
@@ -37,9 +37,7 @@ from . import DeviceFormat, register_device_format
 import iutil
 from flags import flags
 from parted import fileSystemType
-
-# is this nasty?
-log_method_call = iutil.log_method_call
+from storage.storage_log import log_method_call
 
 import logging
 log = logging.getLogger("storage")
diff --git a/storage/formats/luks.py b/storage/formats/luks.py
index 668e689..e7b85f3 100644
--- a/storage/formats/luks.py
+++ b/storage/formats/luks.py
@@ -29,7 +29,7 @@ try:
 except ImportError:
     volume_key = None
 
-from iutil import log_method_call
+from storage.storage_log import log_method_call
 from ..errors import *
 from ..devicelibs import crypto
 from . import DeviceFormat, register_device_format
diff --git a/storage/formats/lvmpv.py b/storage/formats/lvmpv.py
index faec109..6cfddfe 100644
--- a/storage/formats/lvmpv.py
+++ b/storage/formats/lvmpv.py
@@ -22,7 +22,7 @@
 
 import os
 
-from iutil import log_method_call
+from storage.storage_log import log_method_call
 from parted import PARTITION_LVM
 from ..errors import *
 from ..devicelibs import lvm
diff --git a/storage/formats/mdraid.py b/storage/formats/mdraid.py
index 3cc9c2b..a147b12 100644
--- a/storage/formats/mdraid.py
+++ b/storage/formats/mdraid.py
@@ -22,7 +22,7 @@
 
 import os
 
-from iutil import log_method_call
+from storage.storage_log import log_method_call
 from flags import flags
 from parted import PARTITION_RAID
 from ..errors import *
diff --git a/storage/formats/multipath.py b/storage/formats/multipath.py
index fe2702e..0cca51e 100644
--- a/storage/formats/multipath.py
+++ b/storage/formats/multipath.py
@@ -24,7 +24,7 @@
 # Red Hat Author(s): Peter Jones <pjones@xxxxxxxxxx>
 #
 
-from iutil import log_method_call
+from storage.storage_log import log_method_call
 from ..errors import *
 from . import DeviceFormat, register_device_format
 
diff --git a/storage/formats/swap.py b/storage/formats/swap.py
index b1f0d62..8570c17 100644
--- a/storage/formats/swap.py
+++ b/storage/formats/swap.py
@@ -20,8 +20,9 @@
 # Red Hat Author(s): Dave Lehman <dlehman@xxxxxxxxxx>
 #
 
-from iutil import log_method_call, numeric_type
+from iutil import numeric_type
 from parted import PARTITION_SWAP, fileSystemType
+from storage.storage_log import log_method_call
 from ..errors import *
 from ..devicelibs import swap
 from . import DeviceFormat, register_device_format
diff --git a/storage/storage_log.py b/storage/storage_log.py
index a771154..1cea3cf 100644
--- a/storage/storage_log.py
+++ b/storage/storage_log.py
@@ -1,5 +1,22 @@
 import logging
+import inspect
 
+logger = logging.getLogger("storage")
+
+def log_method_call(d, *args, **kwargs):
+    classname = d.__class__.__name__
+    methodname = inspect.stack()[1][3]
+    fmt = "%s.%s:"
+    fmt_args = [classname, methodname]
+    for arg in args:
+        fmt += " %s ;"
+        fmt_args.append(arg)
+
+    for k, v in kwargs.items():
+        fmt += " %s: %s ;"
+        fmt_args.extend([k, v])
+
+    logger.debug(fmt % tuple(fmt_args))
 
 #handler = logging.StreamHandler()
 file_handler = logging.FileHandler("/tmp/storage.log")
@@ -9,9 +26,6 @@ file_handler.setFormatter(formatter)
 tty3_handler = logging.FileHandler("/dev/tty3")
 tty3_handler.setFormatter(formatter)
 
-logger = logging.getLogger("storage")
 logger.addHandler(file_handler)
 logger.addHandler(tty3_handler)
 logger.setLevel(logging.DEBUG)
-
-
-- 
1.6.2.5

_______________________________________________
Anaconda-devel-list mailing list
Anaconda-devel-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/anaconda-devel-list

[Index of Archives]     [Kickstart]     [Fedora Users]     [Fedora Legacy List]     [Fedora Maintainers]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [Yosemite Photos]     [KDE Users]     [Fedora Tools]
  Powered by Linux