Package tlib :: Package base :: Module LogHelper |
[hide private]
[frames] | no frames]

# Source Code for Module tlib.base.LogHelper

     1  import logging
     2  import logging.config
     3  from tlib.base import TestHelper
     4
     5 -def get_tlib_logger():
     6      """
     7      Returns logger named tlib.\n
     8      This logger should only be used by TLib modules. To log from a test or test module use get_test_logger\n
     9      Logger will get flushed at the end to ensure data is not lost if tests exist abnormally
    10      """
    11      config_folder = TestHelper.tlib_config_folder()
    12      try:
    13          logging.config.fileConfig(os.path.join(config_folder, "logging.conf"))
    14      except IOError:
    15          raise IOError("Couldn't create logger object. Make sure log folder exists and " \
    16                      "you have write permissions")
    17
    18      return logging.getLogger("tlib")
    19
    20 -def get_adb_logger():
    21      """
    22      Returns logger named adb.\n
    23      This logger should only be used by adb modules. To log from a test or test module use get_test_logger\n
    24      Logger will get flushed at the end to ensure data is not lost if tests exist abnormally
    25      """
    26      config_folder = TestHelper.adb_config_folder()
    27      try:
    28          logging.config.fileConfig(os.path.join(config_folder, "logging.conf"))
    29      except IOError:
    30          raise IOError("Couldn't create logger object. Make sure log folder exists and " \
    31                      "you have write permissions")
    32
    33      return logging.getLogger("adb")
    34
    35 -def get_test_logger():
    36      """
    37      Returns logger named test.\n
    38      This logger should only be used by test modules. To log from a test or test module use get_test_logger\n
    39      Logger will get flushed at the end to ensure data is not lost if tests exist abnormally
    40      """
    41      config_folder = TestHelper.test_config_folder()
    42      try:
    43          logging.config.fileConfig(os.path.join(config_folder, "logging.conf"))
    44      except IOError:
    45          raise IOError("Couldn't create logger object. Make sure log folder exists and " \
    46                      "you have write permissions")
    47
    48      return logging.getLogger("test")
    49