Skip to content

Commit

Permalink
net: syslog: Make sure CONFIG_LOG_IMMEDIATE is not set
Browse files Browse the repository at this point in the history
The immediate logging option cannot be used with network logging
support CONFIG_LOG_BACKEND_NET as that would cause the generated
rsyslog messages to be malformed. The UDP packets would only have
one byte payloads which is not correct. So make sure that user is
not able to select a configuration with immediate mode and network
logging.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
  • Loading branch information
jukkar committed Nov 27, 2020
1 parent 83b6fa2 commit 6856d4c
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 1 deletion.
5 changes: 5 additions & 0 deletions samples/net/syslog_net/prj.conf
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,11 @@ CONFIG_NET_IF_MCAST_IPV6_ADDR_COUNT=5
CONFIG_NET_LOG=y
CONFIG_LOG=y

# Immediate logging does not work with network syslog as it would cause
# the sent packet to be malformed (contains only 1 byte data)
CONFIG_LOG_IMMEDIATE=n
CONFIG_LOG_PROCESS_THREAD=y

CONFIG_NET_IPV6=y
CONFIG_NET_IPV4=y
CONFIG_NET_DHCPV4=n
Expand Down
2 changes: 2 additions & 0 deletions samples/net/syslog_net/src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ LOG_MODULE_REGISTER(net_syslog, LOG_LEVEL_DBG);
#include <net/net_core.h>
#include <net/net_pkt.h>

BUILD_ASSERT(IS_ENABLED(CONFIG_LOG_BACKEND_NET), "syslog backend not enabled");

#define SLEEP_BETWEEN_PRINTS 3

void main(void)
Expand Down
4 changes: 3 additions & 1 deletion subsys/logging/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -465,9 +465,11 @@ config LOG_BACKEND_XTENSA_OUTPUT_BUFFER_SIZE
Buffer is used by log_output module for preparing output data (e.g.
string formatting).

# Immediate mode cannot be used with network backend as it would cause the sent
# rsyslog message to be malformed.
config LOG_BACKEND_NET
bool "Enable networking backend"
depends on NETWORKING
depends on NETWORKING && NET_UDP && !LOG_IMMEDIATE
select NET_CONTEXT_NET_PKT_POOL
help
Send syslog messages to network server.
Expand Down

0 comments on commit 6856d4c

Please sign in to comment.