Commit c5f2cdef authored by Krzysztof Chruściński's avatar Krzysztof Chruściński Committed by Anas Nashif
Browse files

logging: Remove logging v1 from the logging

Remove v1 implementation from log_core and all references in the tree.
Remove modules used by v1: log_list and log_msg.
Remove Kconfig v1 specific options.
Remove Kconfig flags used for distinction between v1 and v2.

Signed-off-by: default avatarKrzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
parent c9f23499
Loading
Loading
Loading
Loading
+2 −14
Changes for doc/services/logging/index.rst: 2 added lines, 14 removed lines.
Original line number Diff line number Diff line
@@ -123,9 +123,6 @@ allocated.

:kconfig:option:`CONFIG_LOG_PRINTK`: Redirect printk calls to the logging.

:kconfig:option:`CONFIG_LOG_PRINTK_MAX_STRING_LENGTH`: Maximal string length that can
be processed by printk. Longer strings are trimmed.

:kconfig:option:`CONFIG_LOG_PROCESS_TRIGGER_THRESHOLD`: When number of buffered log
messages reaches the threshold dedicated thread (see :c:func:`log_thread_set`)
is waken up. If :kconfig:option:`CONFIG_LOG_PROCESS_THREAD` is enabled then this
@@ -140,20 +137,11 @@ after which logging thread is started.
:kconfig:option:`CONFIG_LOG_BUFFER_SIZE`: Number of bytes dedicated for the circular
packet buffer.

:kconfig:option:`CONFIG_LOG_DETECT_MISSED_STRDUP`: Enable detection of missed transient
strings handling.

:kconfig:option:`CONFIG_LOG_STRDUP_MAX_STRING`: Longest string that can be duplicated
using log_strdup().

:kconfig:option:`CONFIG_LOG_STRDUP_BUF_COUNT`: Number of buffers in the pool used by
log_strdup().

:kconfig:option:`CONFIG_LOG_DOMAIN_ID`: Domain ID. Valid in multi-domain systems.

:kconfig:option`CONFIG_LOG_FRONTEND`: Direct logs to a custom frontend.
:kconfig:option:`CONFIG_LOG_FRONTEND`: Direct logs to a custom frontend.

:kconfig:option`CONFIG_LOG_FRONTEND_ONLY`: No backends are used when messages goes to frontend.
:kconfig:option:`CONFIG_LOG_FRONTEND_ONLY`: No backends are used when messages goes to frontend.

:kconfig:option:`CONFIG_LOG_TIMESTAMP_64BIT`: 64 bit timestamp.

+2 −26
Changes for include/zephyr/logging/log.h: 2 added lines, 26 removed lines.
Original line number Diff line number Diff line
@@ -259,43 +259,19 @@ extern "C" {
 * printk functionality.
 *
 * It is less efficient compared to standard logging because static packaging
 * cannot be used. When CONFIG_LOG1 is used string formatting is performed in the
 * call context and not deferred to the log processing context (@ref log_process).
 * cannot be used.
 *
 * @param fmt Formatted string to output.
 * @param ap  Variable parameters.
 */
void z_log_vprintk(const char *fmt, va_list ap);

/** @brief Copy transient string to a buffer from internal, logger pool.
 *
 * Function should be used when transient string is intended to be logged.
 * Logger allocates a buffer and copies input string returning a pointer to the
 * copy. Logger ensures that buffer is freed when logger message is freed.
 *
 * Depending on configuration, this function may do nothing and just pass
 * along the supplied string pointer. Do not rely on this function to always
 * make a copy!
 *
 * @param str Transient string.
 *
 * @return Copy of the string or default string if buffer could not be
 *	   allocated. String may be truncated if input string does not fit in
 *	   a buffer from the pool (see CONFIG_LOG_STRDUP_MAX_STRING). In
 *	   some configurations, the original string pointer is returned.
 */
char *z_log_strdup(const char *str);
/** @brief Deprecated. */
static inline char *log_strdup(const char *str)
{
	if (IS_ENABLED(CONFIG_LOG_MODE_MINIMAL) ||
	    IS_ENABLED(CONFIG_LOG_FRONTEND) ||
	    IS_ENABLED(CONFIG_LOG2)) {
	return (char *)str;
}

	return z_log_strdup(str);
}

#ifdef __cplusplus
}
#define LOG_IN_CPLUSPLUS 1
+0 −83
Changes for include/zephyr/logging/log_backend.h: 0 added lines, 83 removed lines.
Original line number Diff line number Diff line
@@ -6,7 +6,6 @@
#ifndef ZEPHYR_INCLUDE_LOGGING_LOG_BACKEND_H_
#define ZEPHYR_INCLUDE_LOGGING_LOG_BACKEND_H_

#include <zephyr/logging/log_msg.h>
#include <zephyr/logging/log_msg2.h>
#include <stdarg.h>
#include <zephyr/sys/__assert.h>
@@ -31,21 +30,9 @@ struct log_backend;
 * @brief Logger backend API.
 */
struct log_backend_api {
	/* Logging v2 function. */
	void (*process)(const struct log_backend *const backend,
			union log_msg2_generic *msg);

	/* DEPRECATED! Functions used for logging v1. */
	void (*put)(const struct log_backend *const backend,
		    struct log_msg *msg);
	void (*put_sync_string)(const struct log_backend *const backend,
			 struct log_msg_ids src_level, uint32_t timestamp,
			 const char *fmt, va_list ap);
	void (*put_sync_hexdump)(const struct log_backend *const backend,
			 struct log_msg_ids src_level, uint32_t timestamp,
			 const char *metadata, const uint8_t *data, uint32_t len);

	/* Functions used by v1 and v2 */
	void (*dropped)(const struct log_backend *const backend, uint32_t cnt);
	void (*panic)(const struct log_backend *const backend);
	void (*init)(const struct log_backend *const backend);
@@ -141,22 +128,6 @@ static inline int log_backend_is_ready(const struct log_backend *const backend)
	return 0;
}

/**
 * @brief Put message with log entry to the backend.
 *
 * @warning DEPRECATED. Use logging v2.
 *
 * @param[in] backend  Pointer to the backend instance.
 * @param[in] msg      Pointer to message with log entry.
 */
static inline void log_backend_put(const struct log_backend *const backend,
				   struct log_msg *msg)
{
	__ASSERT_NO_MSG(backend != NULL);
	__ASSERT_NO_MSG(msg != NULL);
	backend->api->put(backend, msg);
}

/**
 * @brief Process message.
 *
@@ -175,58 +146,6 @@ static inline void log_backend_msg2_process(
	backend->api->process(backend, msg);
}


/**
 * @brief Synchronously process log message.
 *
 * @warning DEPRECATED. Use logging v2.
 *
 * @param[in] backend   Pointer to the backend instance.
 * @param[in] src_level Message details.
 * @param[in] timestamp Timestamp.
 * @param[in] fmt       Log string.
 * @param[in] ap        Log string arguments.
 */
static inline void log_backend_put_sync_string(
					const struct log_backend *const backend,
					struct log_msg_ids src_level,
					uint32_t timestamp, const char *fmt,
					va_list ap)
{
	__ASSERT_NO_MSG(backend != NULL);

	if (backend->api->put_sync_string) {
		backend->api->put_sync_string(backend, src_level,
					      timestamp, fmt, ap);
	}
}

/**
 * @brief Synchronously process log hexdump_message.
 *
 * @warning DEPRECATED. Use logging v2.
 *
 * @param[in] backend   Pointer to the backend instance.
 * @param[in] src_level Message details.
 * @param[in] timestamp Timestamp.
 * @param[in] metadata  Raw string associated with the data.
 * @param[in] data      Data.
 * @param[in] len       Data length.
 */
static inline void log_backend_put_sync_hexdump(
					const struct log_backend *const backend,
					struct log_msg_ids src_level,
					uint32_t timestamp, const char *metadata,
					const uint8_t *data, uint32_t len)
{
	__ASSERT_NO_MSG(backend != NULL);

	if (backend->api->put_sync_hexdump) {
		backend->api->put_sync_hexdump(backend, src_level, timestamp,
					       metadata, data, len);
	}
}

/**
 * @brief Notify backend about dropped log messages.
 *
@@ -347,7 +266,6 @@ static inline bool log_backend_is_active(
	return backend->cb->active;
}

#ifndef CONFIG_LOG1
/** @brief Set logging format.
 *
 * @param backend Pointer to the backend instance.
@@ -379,7 +297,6 @@ static inline int log_backend_format_set(const struct log_backend *backend, uint

	return backend->api->format_set(backend, log_type);
}
#endif

/**
 * @}
+1 −101
Changes for include/zephyr/logging/log_backend_std.h: 1 added line, 101 removed lines.
Original line number Diff line number Diff line
@@ -6,7 +6,7 @@
#ifndef ZEPHYR_LOG_BACKEND_STD_H_
#define ZEPHYR_LOG_BACKEND_STD_H_

#include <zephyr/logging/log_msg.h>
#include <zephyr/logging/log_msg2.h>
#include <zephyr/logging/log_output.h>
#include <zephyr/kernel.h>

@@ -36,25 +36,6 @@ static inline uint32_t log_backend_std_get_flags(void)
	return flags;
}

/** @brief Put log message to a standard logger backend.
 *
 * @param output	Log output instance.
 * @param flags		Formatting flags.
 * @param msg		Log message.
 */
static inline void
log_backend_std_put(const struct log_output *const output, uint32_t flags,
		    struct log_msg *msg)
{
	log_msg_get(msg);

	flags |= log_backend_std_get_flags();

	log_output_msg_process(output, msg, flags);

	log_msg_put(msg);
}

/** @brief Put a standard logger backend into panic mode.
 *
 * @param output	Log output instance.
@@ -76,87 +57,6 @@ log_backend_std_dropped(const struct log_output *const output, uint32_t cnt)
	log_output_dropped_process(output, cnt);
}

/** @brief Synchronously process log message by a standard logger backend.
 *
 * @param output	Log output instance.
 * @param flags		Formatting flags.
 * @param src_level	Log message source and level.
 * @param timestamp	Timestamp.
 * @param fmt		Log string.
 * @param ap		Log string arguments.
 */
static inline void
log_backend_std_sync_string(const struct log_output *const output,
			    uint32_t flags, struct log_msg_ids src_level,
			    uint32_t timestamp, const char *fmt, va_list ap)
{
	int key;

	flags |= LOG_OUTPUT_FLAG_LEVEL | LOG_OUTPUT_FLAG_TIMESTAMP;
	if (IS_ENABLED(CONFIG_LOG_BACKEND_SHOW_COLOR)) {
		flags |= LOG_OUTPUT_FLAG_COLORS;
	}

	if (IS_ENABLED(CONFIG_LOG_BACKEND_FORMAT_TIMESTAMP)) {
		flags |= LOG_OUTPUT_FLAG_FORMAT_TIMESTAMP;
	}

	if (IS_ENABLED(CONFIG_LOG_IMMEDIATE_CLEAN_OUTPUT)) {
		/* In order to ensure that one log processing is not interrupted
		 * by another one, lock context for whole log processing.
		 */
		key = irq_lock();
	}

	log_output_string(output, src_level, timestamp, fmt, ap, flags);

	if (IS_ENABLED(CONFIG_LOG_IMMEDIATE_CLEAN_OUTPUT)) {
		irq_unlock(key);
	}
}

/** @brief Synchronously process hexdump message by a standard logger backend.
 *
 * @param output	Log output instance.
 * @param flags		Formatting flags.
 * @param src_level	Log message source and level.
 * @param timestamp	Timestamp.
 * @param metadata	String associated with a hexdump.
 * @param data		Buffer to dump.
 * @param length	Length of the buffer.
 */
static inline void
log_backend_std_sync_hexdump(const struct log_output *const output,
			     uint32_t flags, struct log_msg_ids src_level,
			     uint32_t timestamp, const char *metadata,
			     const uint8_t *data, uint32_t length)
{
	int key;

	flags |= LOG_OUTPUT_FLAG_LEVEL | LOG_OUTPUT_FLAG_TIMESTAMP;
	if (IS_ENABLED(CONFIG_LOG_BACKEND_SHOW_COLOR)) {
		flags |= LOG_OUTPUT_FLAG_COLORS;
	}

	if (IS_ENABLED(CONFIG_LOG_BACKEND_FORMAT_TIMESTAMP)) {
		flags |= LOG_OUTPUT_FLAG_FORMAT_TIMESTAMP;
	}

	if (IS_ENABLED(CONFIG_LOG_IMMEDIATE_CLEAN_OUTPUT)) {
		/* In order to ensure that one log processing is not interrupted
		 * by another one, lock context for whole log processing.
		 */
		key = irq_lock();
	}

	log_output_hexdump(output, src_level, timestamp,
			metadata, data, length, flags);

	if (IS_ENABLED(CONFIG_LOG_IMMEDIATE_CLEAN_OUTPUT)) {
		irq_unlock(key);
	}
}

/**
 * @}
 */
+1 −436

File changed.

Preview size limit exceeded, changes collapsed.

Loading