From 11795d9e10e11000dbf36397f4870fed5635bdc8 Mon Sep 17 00:00:00 2001 From: Brian Dolbec Date: Sat, 22 Jun 2013 12:41:31 -0700 Subject: [PATCH] Make the logger, namespace able. --- gkeyldap/cli.py | 3 +++ gkeys/cli.py | 3 +++ gkeys/log.py | 12 +++++++++++- 3 files changed, 17 insertions(+), 1 deletion(-) diff --git a/gkeyldap/cli.py b/gkeyldap/cli.py index 21e551f..8d9dc85 100644 --- a/gkeyldap/cli.py +++ b/gkeyldap/cli.py @@ -7,7 +7,10 @@ import sys import os import argparse +from gkeys import log +log.set_logger('gkeyldap') from gkeys.log import logger + from gkeys.config import GKeysConfig, GKEY from gkeys.seed import Seeds from gkeyldap.search import (LdapSearch, UID, gkey2ldap_map, gkey2SEARCH) diff --git a/gkeys/cli.py b/gkeys/cli.py index b9846d9..47c8777 100644 --- a/gkeys/cli.py +++ b/gkeys/cli.py @@ -16,7 +16,10 @@ from __future__ import print_function import argparse import sys +from gkeys import log +log.set_logger('gkeys') from gkeys.log import logger + from gkeys.config import GKeysConfig, GKEY from gkeys.seed import Seeds diff --git a/gkeys/log.py b/gkeys/log.py index c0a33e7..4608eba 100644 --- a/gkeys/log.py +++ b/gkeys/log.py @@ -14,5 +14,15 @@ import logging logging.basicConfig() -logger = logging.getLogger('gentoo-keys') +NAMESPACE = 'gentoo-keys' +logger = None + +def set_logger(namespace=None): + global logger, NAMESPACE + if not namespace: + namespace = Namespace + else: + NAMESPACE = namespace + logger = logging.getLogger(namespace) + -- 2.26.2