Rework logging to support importing externally

Right now barbican client is not usable when importing from other
OpenStack modules. This is due to the fact that logging under
barbican.openstack.common wants to do things like register default
CONF options. And, as these have already been registered, this will
fail with exceptions like ArgsAlreadyParsedError.

Therefore, move this client to follow the examples provided by the
other python-*client modules. Namely, import standard logging module
and move the setup into the keep client itself. Now when called from
places like Nova, we will not encounter import issues.

Additionally, this change fixes a bug in barbicanclient.common.auth
where LOG was used but not defined.
This commit is contained in:
Craig Tracey
2013-11-25 12:49:19 -05:00
parent 0e2a97982a
commit 0deaa0ab84
5 changed files with 12 additions and 4 deletions

View File

@@ -13,18 +13,17 @@
# See the License for the specific language governing permissions and
# limitations under the License.
import json
import logging
import os
import requests
from barbicanclient.openstack.common import log as logging
from barbicanclient.openstack.common.gettextutils import _
from barbicanclient import orders
from barbicanclient import secrets
LOG = logging.getLogger(__name__)
logging.setup('barbicanclient')
class HTTPError(Exception):

View File

@@ -12,9 +12,13 @@
# implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import logging
from keystoneclient.v2_0 import client as ksclient
from keystoneclient import exceptions
LOG = logging.getLogger(__name__)
class AuthException(Exception):
"""Raised when authorization fails."""

View File

@@ -19,6 +19,9 @@ import argparse
from barbicanclient.common import auth
from barbicanclient import client
from barbicanclient.openstack.common import log as logging
logging.setup('barbicanclient')
class Keep:

View File

@@ -12,9 +12,10 @@
# implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import logging
from barbicanclient import base
from barbicanclient.openstack.common.gettextutils import _
from barbicanclient.openstack.common import log as logging
from barbicanclient.openstack.common import timeutils

View File

@@ -12,8 +12,9 @@
# implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import logging
from barbicanclient import base
from barbicanclient.openstack.common import log as logging
from barbicanclient.openstack.common.timeutils import parse_isotime