static int t5_all_tests_on_static(void)
{
	if (!enable_test[5])
		return 0;

	log_dest = SMIOC_STATIC_LOG;

	if (log_disabled(log_dest)) {
		printf("INFO %s:%i Static log disabled, skipping tests.\n",
			__func__,
			__LINE__);

		return 0;
	}

	return t4_write_all_log();
}
Exemplo n.º 2
0
/*------------------------------------------------------------------------------
 |    main
 +-----------------------------------------------------------------------------*/
int main(int argc, char** argv)
{
#if defined(QT_QML_LIB) && defined(QT_QUICK_LIB)
   QGuiApplication a(argc, argv);
#endif

#if 0
   QElapsedTimer timer;
   timer.start();

   // Test with lc_logging.
   for (int i = 0; i < 100000; i++)
      log_verbose("Test: %d.", i);
   qDebug("Result lc_logging: %lld.", timer.elapsed());

   // Test with printf.
   timer.restart();
   for (int i = 0; i < 100000; i++) {
      fprintf(stdout, "- DEBUG:%s: Test: %d.\n", lc_current_time().c_str(), i);
      fflush(stdout);
   }
   qDebug("Result printf: %lld.", timer.elapsed());

   // Test with qDebug.
   timer.restart();
   for (int i = 0; i < 100000; i++) {
      qDebug("- DEBUG:%s: Test: %d.\n", lc_current_time().c_str(), i);
      fflush(stderr);
   }
   qDebug("Result qDebug: %lld.", timer.elapsed());
#endif

#ifdef __GNUC__
   LOG_CRITICAL("MyTag", "Oooops!");
#endif

   log_info("Info log.");
   log_info_t("MyTag", "Info log.");
   test_args("Testing %d va_args functions.", 2);

   log_debug("Some message for debugging...");
   log_disabled("A disabled log!!!!!!!!!!! You won't see this.");

   log_critical("Print int: %d.", 5);
   log_critical_t("MyTag", "Print int: %d.", 5);
   log_critical_t("MyTag", "Print with tag only.");

   /*lc_formatted_printf(stdout, LC_LOG_ATTR_UNDERLINE, LC_LOG_COL_MAGENTA,
                     "Underlined %s! ;-)\n", "magenta");*/
   log_formatted(LC_LOG_ATTR_UNDERLINE, LC_LOG_COL_YELLOW, "Formatted text.");
   log_formatted(LC_LOG_COL_YELLOW, "Formatted text with %s.", "param");

#ifndef __ANDROID__
   test_func();
#endif

   // Using streams.
   {
      LC_LogDef logger(NULL, LC_LOG_ATTR_RESET, LC_LOG_COL_BLUE);
      logger.stream() << "Blue log using stream. " << "Params can be added like " << 1234 << ".";

      LC_LogDef l(NULL);
      Q_UNUSED(l);
   }

   {
      LC_Log<LC_Output2Std> logger(LC_LOG_DEBUG);
      logger.stream() << "Debug log with stream.";
   }

   {
      LC_Log<LC_Output2Std> logger(LC_LOG_WARN);
      logger.stream() << "Warning log with stream.";
   }

   {
      LC_Log<LC_Output2Std> logger(LC_LOG_CRITICAL);
      logger.stream() << "Critical log with stream.";
   }

#if defined(QT_QML_LIB) && defined(QT_QUICK_LIB)
   QQuickView view;
   LC_QMLLogger::registerObject(view.rootContext());
   view.setSource(QUrl("qrc:///main.qml"));
#endif

   assert(log_verbose("") == true);
   assert(log_info("") == true);
   assert(log_warn("") == false);
   assert(log_err("") == false);
   assert(log_critical("") == false);

   return 0;
}