From 2c0eb79cd731ce154853f0a8517b8d41a912d428 Mon Sep 17 00:00:00 2001 From: Jianghua Wang Date: Thu, 22 Feb 2018 07:46:03 +0000 Subject: [PATCH] Use module name (__name__) for getLogger() We usually use a period-separated hierarchical module name as the logger's name. But we have three scripts are using a hardcoded name. This commit is to change them to use __name__ to make them consistent with others. By using the period-separated hierarchical module name, it's easier to know which module generated the log lines so it's also easier to get the file name. Change-Id: I373ce9b44caf2b9baffb753e6db7ad8789219f4b --- os_xenapi/utils/common_function.py | 2 +- os_xenapi/utils/conntrack_service.py | 2 +- os_xenapi/utils/sshclient.py | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/os_xenapi/utils/common_function.py b/os_xenapi/utils/common_function.py index e7bfdf1..6672f90 100644 --- a/os_xenapi/utils/common_function.py +++ b/os_xenapi/utils/common_function.py @@ -32,7 +32,7 @@ PATTERN_XENSTORE_VIFS_IN_VM = '/xapi/%s/private/vif' LOG_ROOT = '/var/log/os-xenapi' DEFAULT_LOG_FILE = 'xenapi.log' -LOG = logging.getLogger('XenAPI_utils') +LOG = logging.getLogger(__name__) def exit_with_error(err_msg): diff --git a/os_xenapi/utils/conntrack_service.py b/os_xenapi/utils/conntrack_service.py index 8832538..507443f 100644 --- a/os_xenapi/utils/conntrack_service.py +++ b/os_xenapi/utils/conntrack_service.py @@ -20,7 +20,7 @@ import sys from os_xenapi.utils import common_function from os_xenapi.utils import sshclient -LOG = logging.getLogger('conntrack_service') +LOG = logging.getLogger(__name__) LOG.setLevel(logging.DEBUG) diff --git a/os_xenapi/utils/sshclient.py b/os_xenapi/utils/sshclient.py index 81dae12..69e1b82 100644 --- a/os_xenapi/utils/sshclient.py +++ b/os_xenapi/utils/sshclient.py @@ -20,7 +20,7 @@ import paramiko from os_xenapi.client.exception import OsXenApiException from os_xenapi.client.i18n import _ -LOG = logging.getLogger('SSHClient') +LOG = logging.getLogger(__name__) class SshExecCmdFailure(OsXenApiException):