
from __future__ import absolute_import
from __future__ import unicode_literals

import logbook


logger = logbook.Logger("SimpleSQLie")
logger.disable()


def set_logger(is_enable):
    if is_enable:
        logger.enable()
    else:
        logger.disable()


def set_log_level(log_level):
    """
    Set logging level of this module. Using
    `logbook <http://logbook.readthedocs.io/en/stable/>`__ module for logging.

    :param int log_level:
        One of the log level of
        `logbook <http://logbook.readthedocs.io/en/stable/api/base.html>`__.
        Disabled logging if ``log_level`` is ``logbook.NOTSET``.
    """

    if log_level == logbook.NOTSET:
        set_logger(is_enable=False)
    else:
        set_logger(is_enable=True)
        logger.level = log_level


from __future__ import absolute_import
from __future__ import unicode_literals

import dataproperty
import logbook
import pytablereader


logger = logbook.Logger("SimpleSQLie")
logger.disable()


def set_logger(is_enable):
    if is_enable != logger.disabled:
        return

    if is_enable:
        logger.enable()
    else:
        logger.disable()

    dataproperty.set_logger(is_enable)
    pytablereader.set_logger(is_enable)


def set_log_level(log_level):
    """
    Set logging level of this module. Using
    `logbook <http://logbook.readthedocs.io/en/stable/>`__ module for logging.

    :param int log_level:
        One of the log level of
        `logbook <http://logbook.readthedocs.io/en/stable/api/base.html>`__.
        Disabled logging if ``log_level`` is ``logbook.NOTSET``.
    """

    if log_level == logger.level:
        return

    if log_level == logbook.NOTSET:
        set_logger(is_enable=False)
    else:
        set_logger(is_enable=True)
        logger.level = log_level

    dataproperty.set_log_level(log_level)
    pytablereader.set_log_level(log_level)

Modify to avoid excessive logger initialization
Modify to avoid excessive logger initialization

  
  from __future__ import absolute_import
  from __future__ import unicode_literals
  
+ import dataproperty
  import logbook
+ import pytablereader
  
  
  logger = logbook.Logger("SimpleSQLie")
  logger.disable()
  
  
  def set_logger(is_enable):
+     if is_enable != logger.disabled:
+         return
+ 
      if is_enable:
          logger.enable()
      else:
          logger.disable()
+ 
+     dataproperty.set_logger(is_enable)
+     pytablereader.set_logger(is_enable)
  
  
  def set_log_level(log_level):
      """
      Set logging level of this module. Using
      `logbook <http://logbook.readthedocs.io/en/stable/>`__ module for logging.
  
      :param int log_level:
          One of the log level of
          `logbook <http://logbook.readthedocs.io/en/stable/api/base.html>`__.
          Disabled logging if ``log_level`` is ``logbook.NOTSET``.
      """
  
+     if log_level == logger.level:
+         return
+ 
      if log_level == logbook.NOTSET:
          set_logger(is_enable=False)
      else:
          set_logger(is_enable=True)
          logger.level = log_level
  
+     dataproperty.set_log_level(log_level)
+     pytablereader.set_log_level(log_level)
+ 
Modify to avoid excessive logger initialization
## Code Before:

from __future__ import absolute_import
from __future__ import unicode_literals

import logbook


logger = logbook.Logger("SimpleSQLie")
logger.disable()


def set_logger(is_enable):
    if is_enable:
        logger.enable()
    else:
        logger.disable()


def set_log_level(log_level):
    """
    Set logging level of this module. Using
    `logbook <http://logbook.readthedocs.io/en/stable/>`__ module for logging.

    :param int log_level:
        One of the log level of
        `logbook <http://logbook.readthedocs.io/en/stable/api/base.html>`__.
        Disabled logging if ``log_level`` is ``logbook.NOTSET``.
    """

    if log_level == logbook.NOTSET:
        set_logger(is_enable=False)
    else:
        set_logger(is_enable=True)
        logger.level = log_level

## Instruction:
Modify to avoid excessive logger initialization
## Code After:

from __future__ import absolute_import
from __future__ import unicode_literals

import dataproperty
import logbook
import pytablereader


logger = logbook.Logger("SimpleSQLie")
logger.disable()


def set_logger(is_enable):
    if is_enable != logger.disabled:
        return

    if is_enable:
        logger.enable()
    else:
        logger.disable()

    dataproperty.set_logger(is_enable)
    pytablereader.set_logger(is_enable)


def set_log_level(log_level):
    """
    Set logging level of this module. Using
    `logbook <http://logbook.readthedocs.io/en/stable/>`__ module for logging.

    :param int log_level:
        One of the log level of
        `logbook <http://logbook.readthedocs.io/en/stable/api/base.html>`__.
        Disabled logging if ``log_level`` is ``logbook.NOTSET``.
    """

    if log_level == logger.level:
        return

    if log_level == logbook.NOTSET:
        set_logger(is_enable=False)
    else:
        set_logger(is_enable=True)
        logger.level = log_level

    dataproperty.set_log_level(log_level)
    pytablereader.set_log_level(log_level)
