summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorkundatipradeep <35292742+kundatipradeep@users.noreply.github.com>2018-04-27 17:36:53 +0530
committerChristoph Lipka <clipka@users.noreply.github.com>2018-04-27 14:06:53 +0200
commita7452aa09ae2442c83ef879c7076ed57b9e9ece5 (patch)
tree397a78a3f0fdb3c57a9c475d5a8cc02dcfd97e69 /src
parent90c8b5b2890a227088b5a67a21bdc24028b156d5 (diff)
downloadDLT-daemon-a7452aa09ae2442c83ef879c7076ed57b9e9ece5.tar.gz
Fix ForceContextLogLevelAndTraceStatus handling in dlt_daemon_client.c (#50)
Even Forcing log level and trace status of context to not exceed "ContextLogLevel" and "ContextTraceStatus" in dlt.conf file with ForceContextLogLevelAndTraceStatus = 1, the default log level is being overwritten with high value than expected by client(DLT_Viewer when default trace data request is sent ) and by dlt-control application on usage of (dlt-control -d loglevel IP_ADDRESS) With provided patch/changes in place, when ForceContextLogLevelAndTraceStatus is enabled the requested log level is checked with ContextLogLevel and if it satisfied the daemon default loglevel gets updated. Added a conditional checks to not to overwrite the individual contextLoglevel and ContextTracesStatus when ForceContextLogLevelAndTraceStatus is enabled in dlt.conf file and taken care of review comments.
Diffstat (limited to 'src')
-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);