summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/daemon/dlt_daemon_client.c37
1 files changed, 33 insertions, 4 deletions
diff --git a/src/daemon/dlt_daemon_client.c b/src/daemon/dlt_daemon_client.c
index a9d9440..48f38ad 100644
--- a/src/daemon/dlt_daemon_client.c
+++ b/src/daemon/dlt_daemon_client.c
@@ -82,6 +82,20 @@
/** Global text output buffer, mainly used for creation of error/warning strings */
static char str[DLT_DAEMON_TEXTBUFSIZE];
+/** Inline function to calculate/set the requested log level or traces status
+ * with default log level or trace status when "ForceContextLogLevelAndTraceStatus"
+ * is enabled and set to 1 in dlt.conf file.
+ *
+ * @param request_log The requested log level (or) trace status
+ * @param context_log The default log level (or) trace status
+ *
+ * @return The log level if requested log level is lower or equal to ContextLogLevel
+*/
+static inline int8_t getStatus(uint8_t request_log, int context_log)
+{
+ return (request_log <= context_log)? request_log : context_log;
+}
+
/** @brief Sends up to 2 messages to all the clients.
*
* Runs through the client list and sends the messages to them. If the message
@@ -1633,6 +1647,8 @@ void dlt_daemon_control_set_log_level(int sock, DltDaemon *daemon, DltDaemonLoca
}
req = (DltServiceSetLogLevel*) (msg->databuffer);
+ if (daemon_local->flags.enforceContextLLAndTS)
+ req->log_level = getStatus(req->log_level, daemon_local->flags.contextLogLevel);
dlt_set_id(apid, req->apid);
dlt_set_id(ctid, req->ctid);
@@ -1703,7 +1719,10 @@ void dlt_daemon_control_set_trace_status(int sock, DltDaemon *daemon, DltDaemonL
if (context!=0)
{
old_trace_status = context->trace_status;
- context->trace_status = req->log_level; /* No endianess conversion necessary */
+ if (daemon_local->flags.enforceContextLLAndTS)
+ context->trace_status = getStatus(req->log_level, daemon_local->flags.contextTraceStatus);
+ else
+ context->trace_status = req->log_level; /* No endianess conversion necessary */
if ((context->user_handle >= DLT_FD_MINIMUM ) &&
(dlt_daemon_user_send_log_level(daemon, context, verbose)==0))
@@ -1747,7 +1766,10 @@ void dlt_daemon_control_set_default_log_level(int sock, DltDaemon *daemon, DltDa
if (/*(req->log_level>=0) &&*/
(req->log_level<=DLT_LOG_VERBOSE))
{
- daemon->default_log_level = req->log_level; /* No endianess conversion necessary */
+ if (daemon_local->flags.enforceContextLLAndTS)
+ daemon->default_log_level = getStatus(req->log_level, daemon_local->flags.contextLogLevel);
+ else
+ daemon->default_log_level = req->log_level; /* No endianess conversion necessary */
/* Send Update to all contexts using the default log level */
dlt_daemon_user_send_default_update(daemon, verbose);
@@ -1783,7 +1805,11 @@ void dlt_daemon_control_set_all_log_level(int sock, DltDaemon *daemon, DltDaemon
/* No endianess conversion necessary */
if ((req != NULL) && (req->log_level <= DLT_LOG_VERBOSE))
{
- loglevel = req->log_level; /* No endianess conversion necessary */
+ if (daemon_local->flags.enforceContextLLAndTS)
+ loglevel = getStatus(req->log_level, daemon_local->flags.contextLogLevel);
+ else
+ loglevel = req->log_level; /* No endianess conversion necessary */
+
/* Send Update to all contexts using the new log level */
dlt_daemon_user_send_all_update(daemon, loglevel, verbose);
@@ -1819,7 +1845,10 @@ void dlt_daemon_control_set_default_trace_status(int sock, DltDaemon *daemon, Dl
if ((req->log_level==DLT_TRACE_STATUS_OFF) ||
(req->log_level==DLT_TRACE_STATUS_ON))
{
- daemon->default_trace_status = req->log_level; /* No endianess conversion necessary*/
+ if (daemon_local->flags.enforceContextLLAndTS)
+ daemon->default_trace_status = getStatus(req->log_level, daemon_local->flags.contextTraceStatus);
+ else
+ daemon->default_trace_status = req->log_level; /* No endianess conversion necessary*/
/* Send Update to all contexts using the default trace status */
dlt_daemon_user_send_default_update(daemon, verbose);