def test_must_unset_get_debug_flag(self): ctx = Context() message_record = logging.makeLogRecord({"msg": "hello world"}) timestamp_log_regex = re.compile(r"^[0-9:\- ,]+ \| .*$") sam_cli_logger = logging.getLogger(SAM_CLI_LOGGER_NAME) lambda_builders_logger = logging.getLogger(LAMBDA_BULDERS_LOGGER_NAME) SamCliLogger.configure_logger(sam_cli_logger, SAM_CLI_FORMATTER, logging.INFO) SamCliLogger.configure_logger(lambda_builders_logger, SAM_CLI_FORMATTER, logging.INFO) handlers = [ logging.getLogger(SAM_CLI_LOGGER_NAME).handlers[0], logging.getLogger(LAMBDA_BULDERS_LOGGER_NAME).handlers[0], ] # timestamp should not be output for handler in handlers: self.assertNotRegex(handler.formatter.format(message_record), timestamp_log_regex) ctx.debug = True self.assertEqual(ctx.debug, True, "debug must be set to True") # timestamp should be output for handler in handlers: self.assertRegex( handler.formatter.format(message_record), timestamp_log_regex, "debug log record should contain timestamps", ) # Flipping from True to False ctx.debug = False self.assertEqual(ctx.debug, False, "debug must be set to False")
def test_must_unset_get_debug_flag(self): ctx = Context() ctx.debug = True self.assertEquals(ctx.debug, True, "debug must be set to True") # Flipping from True to False ctx.debug = False self.assertEquals(ctx.debug, False, "debug must be set to False")
def test_must_set_get_debug_flag(self): ctx = Context() ctx.debug = True self.assertEquals(ctx.debug, True, "debug must be set to True") self.assertEquals(logging.getLogger().getEffectiveLevel(), logging.DEBUG)
def test_must_set_get_debug_flag(self): ctx = Context() ctx.debug = True self.assertEqual(ctx.debug, True, "debug must be set to True") self.assertEqual(logging.getLogger("samcli").getEffectiveLevel(), logging.DEBUG) self.assertEqual(logging.getLogger("aws_lambda_builders").getEffectiveLevel(), logging.DEBUG)
def test_must_set_get_debug_flag(self): ctx = Context() ctx.debug = True self.assertEqual(ctx.debug, True, "debug must be set to True") self.assertEqual( logging.getLogger(SAM_CLI_LOGGER_NAME).getEffectiveLevel(), logging.DEBUG) self.assertEqual( logging.getLogger(LAMBDA_BULDERS_LOGGER_NAME).getEffectiveLevel(), logging.DEBUG)