Beispiel #1
0
    def testBasicFormat(self):
        """
        Test basic log output with default configuration but using
        the f variants.
        Since the default threshold is INFO, the DEBUG or TRACE
        message is not emitted.
        """
        with TestLog.StdoutCapture(self.outputFilename):
            log.configure()
            log.logf(log.getDefaultLoggerName(),
                     log.INFO,
                     "This is {{INFO}} Item 1: {item[1]}",
                     item=["a", "b", "c"])
            log.infof(u"This is {unicode} INFO")
            log.tracef("This is TRACE")
            log.debugf("This is DEBUG")
            log.warnf("This is WARN {city}", city="Tucson")
            log.errorf("This is ERROR {1}->{0}", 2, 1)
            log.fatalf("This is FATAL {1} out of {0} times for {place}",
                       4,
                       3,
                       place="LSST")
            log.warnf("Format {} {} {}", 3, 2.71828, "foo")
        self.check("""
root INFO: This is {INFO} Item 1: b
root INFO: This is {unicode} INFO
root WARN: This is WARN Tucson
root ERROR: This is ERROR 1->2
root FATAL: This is FATAL 3 out of 4 times for LSST
root WARN: Format 3 2.71828 foo
""")
Beispiel #2
0
def get_logger(log_level):
    """
    Set up standard logging module and set lsst.log to the same log
    level.

    Parameters
    ----------
    log_level : str
        This is converted to logging.<log_level> and set in the logging
        config.
    """
    # Setup logging output.
    logging.basicConfig(format="%(message)s", stream=sys.stdout)
    logger = logging.getLogger()
    logger.setLevel(eval('logging.' + log_level))

    # Set similar logging level for Stack code.
    if log_level == "CRITICAL":
        log_level = "FATAL"
    lsstLog.setLevel(lsstLog.getDefaultLoggerName(),
                     eval('lsstLog.%s' % log_level))

    return logger
Beispiel #3
0
    def testBasic(self):
        """
        Test basic log output with default configuration.
        Since the default threshold is INFO, the DEBUG or TRACE
        message is not emitted.
        """
        with TestLog.StdoutCapture(self.outputFilename):
            log.configure()
            log.log(log.getDefaultLoggerName(), log.INFO, "This is INFO")
            log.info(u"This is unicode INFO")
            log.trace("This is TRACE")
            log.debug("This is DEBUG")
            log.warn("This is WARN")
            log.error("This is ERROR")
            log.fatal("This is FATAL")
            log.warn("Format %d %g %s", 3, 2.71828, "foo")
        self.check("""
root INFO: This is INFO
root INFO: This is unicode INFO
root WARN: This is WARN
root ERROR: This is ERROR
root FATAL: This is FATAL
root WARN: Format 3 2.71828 foo
""")
Beispiel #4
0
    def testBasic(self):
        """
        Test basic log output with default configuration.
        Since the default threshold is INFO, the DEBUG or TRACE
        message is not emitted.
        """
        with TestLog.StdoutCapture(self.outputFilename):
            log.configure()
            log.log(log.getDefaultLoggerName(), log.INFO, "This is INFO")
            log.info(u"This is unicode INFO")
            log.trace("This is TRACE")
            log.debug("This is DEBUG")
            log.warn("This is WARN")
            log.error("This is ERROR")
            log.fatal("This is FATAL")
            log.warn("Format %d %g %s", 3, 2.71828, "foo")
        self.check("""
root INFO: This is INFO
root INFO: This is unicode INFO
root WARN: This is WARN
root ERROR: This is ERROR
root FATAL: This is FATAL
root WARN: Format 3 2.71828 foo
""")
Beispiel #5
0
 def testDefaultLogger(self):
     """Check the default root logger name."""
     self.assertEqual(log.getDefaultLoggerName(), "")
Beispiel #6
0
 def testDefaultLogger(self):
     """Check the default root logger name."""
     self.assertEqual(log.getDefaultLoggerName(), "")