summaryrefslogtreecommitdiff
path: root/src/examples
diff options
context:
space:
mode:
authorStefan Vacek <stefan.vacek@intel.com>2015-08-26 17:28:54 +0200
committerAlexander Wenzel <Alexander.AW.Wenzel@bmw.de>2015-10-07 10:35:41 +0200
commitc3b53f8805236cb7c72eb62ef04866f34de33103 (patch)
tree956eec44e2d0b2ec309904f15321565a3fae4e3d /src/examples
parent2f334a851fa1b39cab74724f3d0a0565f86c27b4 (diff)
downloadDLT-daemon-c3b53f8805236cb7c72eb62ef04866f34de33103.tar.gz
Add env-var to set initial log-levels
name of environment variable: DLT_INITIAL_LOG_LEVEL Syntax: <apid1>:<ctid1>:<loglevel1>;<apid2>:<ctid2>:<loglevel2>;... apid: application id (up to 4 chars), if empty all applications will match ctid: context id (up to 4 chars), if empty all contexts will match loglevel: either -1..6 or a symbolic name (default, off, fatal, error, warning, info, debug, verbose) Examples: DLT_INITIAL_LOG_LEVEL=TEST:LOG:0 -> turn off logging for appid TEST and contextid LOG DLT_INITIAL_LOG_LEVEL=:LOG:warn -> for contexts with name "LOG" set log-level to warning (3) DLT_INITIAL_LOG_LEVEL=::VERBOSE -> set log-level of all contexts to VERBOSE DLT_INITIAL_LOG_LEVEL=::VERBOSE;TEST:LOG:3 -> set log-level of all contexts to VERBOSE except TEST:LOG, set this to WARNING dlt-example-user: add option -l to specify log-level to be used when sending messages Signed-off-by: Stefan Vacek <stefan.vacek@intel.com>
Diffstat (limited to 'src/examples')
-rw-r--r--src/examples/dlt-example-user.c21
1 files changed, 14 insertions, 7 deletions
diff --git a/src/examples/dlt-example-user.c b/src/examples/dlt-example-user.c
index e428047..5f4abc9 100644
--- a/src/examples/dlt-example-user.c
+++ b/src/examples/dlt-example-user.c
@@ -101,6 +101,7 @@ void usage()
printf(" -a Enable local printing of DLT messages (Default: disabled)\n");
printf(" -k Send marker message\n");
printf(" -m mode Set log mode 0=off,1=external,2=internal,3=both\n");
+ printf(" -l level Set log level to <level>, level=-1..6\n");
#ifdef DLT_TEST_ENABLE
printf(" -c Corrupt user header\n");
printf(" -s size Corrupt message size\n");
@@ -126,6 +127,7 @@ int main(int argc, char* argv[])
char *nvalue = 0;
char *mvalue = 0;
char *message = 0;
+ int lvalue = DLT_LOG_WARN;
int index;
int c;
@@ -138,9 +140,9 @@ int main(int argc, char* argv[])
opterr = 0;
#ifdef DLT_TEST_ENABLE
- while ((c = getopt (argc, argv, "vgakcd:f:n:m:z:s:")) != -1)
+ while ((c = getopt (argc, argv, "vgakcd:f:n:m:z:s:l:")) != -1)
#else
- while ((c = getopt (argc, argv, "vgakd:f:n:m:")) != -1)
+ while ((c = getopt (argc, argv, "vgakd:f:n:m:l:")) != -1)
#endif /* DLT_TEST_ENABLE */
{
switch (c)
@@ -197,9 +199,14 @@ int main(int argc, char* argv[])
mvalue = optarg;
break;
}
+ case 'l':
+ {
+ lvalue = atoi(optarg);
+ break;
+ }
case '?':
{
- if (optopt == 'd' || optopt == 'f' || optopt == 'n')
+ if (optopt == 'd' || optopt == 'f' || optopt == 'n'|| optopt == 'l')
{
fprintf (stderr, "Option -%c requires an argument.\n", optopt);
}
@@ -239,7 +246,7 @@ int main(int argc, char* argv[])
if (fvalue)
{
- /* DLT is intialised automatically, except another output target will be used */
+ /* DLT is initialized automatically, except another output target will be used */
if (dlt_init_file(fvalue)<0) /* log to file */
{
return -1;
@@ -262,7 +269,7 @@ int main(int argc, char* argv[])
if(mvalue)
{
printf("Set log mode to %d\n",atoi(mvalue));
- dlt_set_log_mode(atoi(mvalue));
+ dlt_set_log_mode(atoi(mvalue));
}
@@ -354,12 +361,12 @@ int main(int argc, char* argv[])
if (gflag)
{
/* Non-verbose mode */
- DLT_LOG_ID(mycontext,DLT_LOG_WARN,num,DLT_INT(num),DLT_STRING(text));
+ DLT_LOG_ID(mycontext,lvalue,num,DLT_INT(num),DLT_STRING(text));
}
else
{
/* Verbose mode */
- DLT_LOG(mycontext,DLT_LOG_WARN,DLT_INT(num),DLT_STRING(text));
+ DLT_LOG(mycontext,lvalue,DLT_INT(num),DLT_STRING(text));
}
if (delay>0)