sim: log: add new level targetting simulator

* Adds a new level (BOOT_LOG_SIM) to be used only for messages that
  are interesting while debugging bootutil in the simulator. This should
  be used for extra verbose prints.

* Also added fflushs after fprints to guarantee that messages are printed
  even when assertions are raised.

* For abstraction completeness, add "do nothing" definitions of _LOG_SIM
  to the other ports.

* Make DEBUG the default level when building the simulator (one can
  still lower verbosity using any other value for RUST_LOG).

Signed-off-by: Fabio Utzig <utzig@apache.org>
diff --git a/sim/mcuboot-sys/csupport/mcuboot_config/mcuboot_logging.h b/sim/mcuboot-sys/csupport/mcuboot_config/mcuboot_logging.h
index 5f99ac3..bb4ff30 100644
--- a/sim/mcuboot-sys/csupport/mcuboot_config/mcuboot_logging.h
+++ b/sim/mcuboot-sys/csupport/mcuboot_config/mcuboot_logging.h
@@ -27,6 +27,7 @@
 #define MCUBOOT_LOG_LEVEL_WARNING  2
 #define MCUBOOT_LOG_LEVEL_INFO     3
 #define MCUBOOT_LOG_LEVEL_DEBUG    4
+#define MCUBOOT_LOG_LEVEL_SIM      5  /* RUST_LOG=trace */
 
 /*
  * The compiled log level determines the maximum level that can be
@@ -35,7 +36,7 @@
  * setting RUST_LOG to bootsim::api=info.
  */
 #ifndef MCUBOOT_LOG_LEVEL
-#define MCUBOOT_LOG_LEVEL MCUBOOT_LOG_LEVEL_INFO
+#define MCUBOOT_LOG_LEVEL MCUBOOT_LOG_LEVEL_DEBUG
 #endif
 
 #define MCUBOOT_LOG_MODULE_DECLARE(domain)	/* ignore */
@@ -48,6 +49,7 @@
     do {                                                                \
         if (sim_log_enabled(MCUBOOT_LOG_LEVEL_ERROR)) {                 \
             fprintf(stderr, "[ERR] " _fmt "\n", ##__VA_ARGS__);         \
+            fflush(stderr);                                             \
         }                                                               \
     } while (0)
 #else
@@ -59,6 +61,7 @@
     do {                                                                \
         if (sim_log_enabled(MCUBOOT_LOG_LEVEL_WARNING)) {               \
             fprintf(stderr, "[WRN] " _fmt "\n", ##__VA_ARGS__);         \
+            fflush(stderr);                                             \
         }                                                               \
     } while (0)
 #else
@@ -70,6 +73,7 @@
     do {                                                                \
         if (sim_log_enabled(MCUBOOT_LOG_LEVEL_INFO)) {                  \
             fprintf(stderr, "[INF] " _fmt "\n", ##__VA_ARGS__);         \
+            fflush(stderr);                                             \
         }                                                               \
     } while (0)
 #else
@@ -81,10 +85,23 @@
     do {                                                                \
         if (sim_log_enabled(MCUBOOT_LOG_LEVEL_DEBUG)) {                 \
             fprintf(stderr, "[DBG] " _fmt "\n", ##__VA_ARGS__);         \
+            fflush(stderr);                                             \
         }                                                               \
     } while (0)
 #else
 #define MCUBOOT_LOG_DBG(...) IGNORE(__VA_ARGS__)
 #endif
 
+#if MCUBOOT_LOG_LEVEL >= MCUBOOT_LOG_LEVEL_SIM
+#define MCUBOOT_LOG_SIM(_fmt, ...)                                      \
+    do {                                                                \
+        if (sim_log_enabled(MCUBOOT_LOG_LEVEL_SIM)) {                   \
+            fprintf(stderr, "[SIM] " _fmt "\n", ##__VA_ARGS__);         \
+            fflush(stderr);                                             \
+        }                                                               \
+    } while (0)
+#else
+#define MCUBOOT_LOG_SIM(...) IGNORE(__VA_ARGS__)
+#endif
+
 #endif /* __MCUBOOT_LOGGING_H__ */
diff --git a/sim/mcuboot-sys/src/api.rs b/sim/mcuboot-sys/src/api.rs
index f38d98e..a474e8f 100644
--- a/sim/mcuboot-sys/src/api.rs
+++ b/sim/mcuboot-sys/src/api.rs
@@ -209,7 +209,8 @@
         1 => log_enabled!(Level::Error),
         2 => log_enabled!(Level::Warn),
         3 => log_enabled!(Level::Info),
-        4 => log_enabled!(Level::Trace),
+        4 => log_enabled!(Level::Debug),
+        5 => log_enabled!(Level::Trace), // log level == SIM
         _ => false,
     };
     if res {