eal: simplify meson build of common directory
[dpdk.git] / lib / librte_eal / common / include / rte_log.h
index 5f4799e..a497e19 100644 (file)
@@ -20,10 +20,12 @@ extern "C" {
 #include <stdint.h>
 #include <stdio.h>
 #include <stdarg.h>
+#include <stdbool.h>
 #include <sys/queue.h>
 
 #include <rte_common.h>
 #include <rte_config.h>
+#include <rte_compat.h>
 
 struct rte_log_dynamic_type;
 
@@ -36,7 +38,7 @@ struct rte_logs {
        struct rte_log_dynamic_type *dynamic_types;
 };
 
-/** Global log informations */
+/** Global log information */
 extern struct rte_logs rte_logs;
 
 /* SDK log type */
@@ -85,32 +87,6 @@ extern struct rte_logs rte_logs;
 #define RTE_LOG_INFO     7U  /**< Informational.                    */
 #define RTE_LOG_DEBUG    8U  /**< Debug-level messages.             */
 
-/**
- * @warning
- * @b EXPERIMENTAL: this API may change without prior notice
- *
- * Entry definition for the storage to keep EAL log level options
- * which are found to have log type regular expressions specified.
- */
-struct rte_eal_opt_loglevel {
-       /** Next list entry */
-       TAILQ_ENTRY(rte_eal_opt_loglevel) next;
-       /** Regular expression string obtained from the option */
-       char *re_type;
-       /** Log level value obtained from the option */
-       uint32_t level;
-};
-
-TAILQ_HEAD(rte_eal_opt_loglevel_list, rte_eal_opt_loglevel);
-
-/**
- * @warning
- * @b EXPERIMENTAL: this API may change without prior notice
- *
- * Global list of EAL log level options featuring log type expressions
- */
-extern struct rte_eal_opt_loglevel_list opt_loglevel_list;
-
 /**
  * Change the stream that will be used by the logging system.
  *
@@ -126,6 +102,19 @@ extern struct rte_eal_opt_loglevel_list opt_loglevel_list;
  */
 int rte_openlog_stream(FILE *f);
 
+/**
+ * @warning
+ * @b EXPERIMENTAL: this API may change without prior notice
+ *
+ * Retrieve the stream used by the logging system (see rte_openlog_stream()
+ * to change it).
+ *
+ * @return
+ *   Pointer to the stream.
+ */
+__rte_experimental
+FILE *rte_log_get_stream(void);
+
 /**
  * Set the global log level.
  *
@@ -156,16 +145,41 @@ uint32_t rte_log_get_global_level(void);
 int rte_log_get_level(uint32_t logtype);
 
 /**
- * Set the log level for a given type.
+ * For a given `logtype`, check if a log with `loglevel` can be printed.
+ *
+ * @param logtype
+ *   The log type identifier
+ * @param loglevel
+ *   Log level. A value between RTE_LOG_EMERG (1) and RTE_LOG_DEBUG (8).
+ * @return
+ * Returns 'true' if log can be printed and 'false' if it can't.
+ */
+__rte_experimental
+bool rte_log_can_log(uint32_t logtype, uint32_t loglevel);
+
+/**
+ * Set the log level for a given type based on shell pattern.
  *
  * @param pattern
- *   The regexp identifying the log type.
+ *   The match pattern identifying the log type.
+ * @param level
+ *   The level to be set.
+ * @return
+ *   0 on success, a negative value if level is invalid.
+ */
+int rte_log_set_level_pattern(const char *pattern, uint32_t level);
+
+/**
+ * Set the log level for a given type based on regular expression.
+ *
+ * @param regex
+ *   The regular expression identifying the log type.
  * @param level
  *   The level to be set.
  * @return
  *   0 on success, a negative value if level is invalid.
  */
-int rte_log_set_level_regexp(const char *pattern, uint32_t level);
+int rte_log_set_level_regexp(const char *regex, uint32_t level);
 
 /**
  * Set the log level for a given type.
@@ -240,6 +254,7 @@ int rte_log_register(const char *name);
  *    - >=0: the newly registered log type
  *    - <0: rte_log_register() error value
  */
+__rte_experimental
 int rte_log_register_type_and_pick_level(const char *name, uint32_t level_def);
 
 /**
@@ -281,7 +296,7 @@ int rte_log(uint32_t level, uint32_t logtype, const char *format, ...)
        __attribute__((cold))
 #endif
 #endif
-       __attribute__((format(printf, 3, 4)));
+       __rte_format_printf(3, 4);
 
 /**
  * Generates a log message.
@@ -310,7 +325,7 @@ int rte_log(uint32_t level, uint32_t logtype, const char *format, ...)
  *   - Negative on error.
  */
 int rte_vlog(uint32_t level, uint32_t logtype, const char *format, va_list ap)
-       __attribute__((format(printf,3,0)));
+       __rte_format_printf(3, 0);
 
 /**
  * Generates a log message.