summaryrefslogtreecommitdiffstats
path: root/src/software/openlmi/software/yumdb/util.py
diff options
context:
space:
mode:
authorMichal Minar <miminar@redhat.com>2013-04-05 11:19:33 +0200
committerMichal Minar <miminar@redhat.com>2013-04-11 13:52:20 +0200
commit9971c6427fc81021de16931f342d8a2304ecc935 (patch)
tree5fe8cf5a3ba6635ec5cf386d04832f1a3b2c2c44 /src/software/openlmi/software/yumdb/util.py
parent4483f46e192a63d5281acd9a381f1772bbec8a2c (diff)
downloadopenlmi-providers-9971c6427fc81021de16931f342d8a2304ecc935.tar.gz
openlmi-providers-9971c6427fc81021de16931f342d8a2304ecc935.tar.xz
openlmi-providers-9971c6427fc81021de16931f342d8a2304ecc935.zip
docu updated and fixed on some places
also some tab/spaces fixes
Diffstat (limited to 'src/software/openlmi/software/yumdb/util.py')
-rw-r--r--src/software/openlmi/software/yumdb/util.py45
1 files changed, 45 insertions, 0 deletions
diff --git a/src/software/openlmi/software/yumdb/util.py b/src/software/openlmi/software/yumdb/util.py
index f2af151..bd2a0ca 100644
--- a/src/software/openlmi/software/yumdb/util.py
+++ b/src/software/openlmi/software/yumdb/util.py
@@ -1,3 +1,28 @@
+# Software Management Providers
+#
+# Copyright (C) 2012-2013 Red Hat, Inc. All rights reserved.
+#
+# This library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License as published by the Free Software Foundation; either
+# version 2.1 of the License, or (at your option) any later version.
+#
+# This library 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
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this library; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+#
+# Authors: Michal Minar <miminar@redhat.com>
+#
+
+"""
+Common utilities meant to be used only be ``yumdb`` subpackage.
+"""
+
from itertools import chain
import inspect
import logging
@@ -6,7 +31,18 @@ import os
from openlmi.software.yumdb import errors
class DispatchingFormatter:
+ """
+ Formatter class for logging module. It allows to predefine different
+ format string for paricular module names.
+ """
def __init__(self, formatters, default):
+ """
+ *format* in parameters description can be either ``string`` or
+ another formatter object.
+
+ :param formatters (``dict``) Mapping of module names to *format*.
+ :param default Default *format*.
+ """
for k, formatter in formatters.items():
if isinstance(formatter, basestring):
formatters[k] = logging.Formatter(formatter)
@@ -16,6 +52,9 @@ class DispatchingFormatter:
self._default_formatter = default
def format(self, record):
+ """
+ Interface for logging module.
+ """
formatter = self._formatters.get(record.name, self._default_formatter)
return formatter.format(record)
@@ -89,6 +128,12 @@ def trace_function(func):
return _wrapper
def setup_logging(config):
+ """
+ This is meant to be used by ``YumWorker`` process to setup logging
+ independent of what providers are using. Unfortunately ``YumWorker``
+ can not use the same facilities as the rest of program, because
+ logging is done through *broker*.
+ """
try:
logging.config.dictConfig(config)
except Exception: #pylint: disable=W0703