Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
M
Mock Turtle
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
1
Issues
1
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Wiki
Wiki
image/svg+xml
Discourse
Discourse
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Projects
Mock Turtle
Commits
f8d5f0b1
Commit
f8d5f0b1
authored
Jul 10, 2015
by
Federico Vaga
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
wrtd:lib: add more convertion function log-level <-> string
Signed-off-by:
Federico Vaga
<
federico.vaga@cern.ch
>
parent
6158e985
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
53 additions
and
0 deletions
+53
-0
libwrtd-logging.c
applications/wrtd/lib/libwrtd-logging.c
+51
-0
libwrtd.h
applications/wrtd/lib/libwrtd.h
+2
-0
No files found.
applications/wrtd/lib/libwrtd-logging.c
View file @
f8d5f0b1
...
...
@@ -7,6 +7,7 @@
#include <stdlib.h>
#include <unistd.h>
#include <errno.h>
#include <string.h>
#include <libwrnc.h>
#include <libwrtd-internal.h>
#include <wrtd-serializers.h>
...
...
@@ -41,6 +42,56 @@ const char *wrtd_strlogging(enum wrtd_log_level lvl)
}
/**
* It returns the full string describing the log_level in use
* @param[out] buf where write the string
* @param[in] log_level the log level to describe
*/
void
wrtd_strlogging_full
(
char
*
buf
,
uint32_t
log_level
)
{
enum
wrtd_log_level
lvl
;
if
(
!
log_level
)
{
/* No log level */
strcpy
(
buf
,
wrtd_strlogging
(
log_level
));
return
;
}
strcpy
(
buf
,
""
);
for
(
lvl
=
0x1
;
lvl
<=
WRTD_LOG_MISSED
;
lvl
<<=
1
)
{
if
(
lvl
&
log_level
)
{
strcat
(
buf
,
wrtd_strlogging
(
lvl
));
strcat
(
buf
,
" "
);
}
}
}
/**
* It converts a given logging string into a log_level
* @param[in] log string log level
* @return the correspondent log level enum
*/
enum
wrtd_log_level
wrtd_strlogging_to_level
(
char
*
log
)
{
if
(
!
strcmp
(
log
,
"all"
))
return
WRTD_LOG_ALL
;
if
(
!
strcmp
(
log
,
"promiscious"
))
return
WRTD_LOG_PROMISC
;
if
(
!
strcmp
(
log
,
"raw"
))
return
WRTD_LOG_RAW
;
if
(
!
strcmp
(
log
,
"executed"
))
return
WRTD_LOG_EXECUTED
;
if
(
!
strcmp
(
log
,
"missed"
))
return
WRTD_LOG_MISSED
;
if
(
!
strcmp
(
log
,
"sent"
))
return
WRTD_LOG_SENT
;
if
(
!
strcmp
(
log
,
"filtered"
))
return
WRTD_LOG_FILTERED
;
return
WRTD_LOG_NOTHING
;
}
/**
* It opens the logging interface for a given divice. The default
* logging level will be applied to all device channels. You can change it
...
...
applications/wrtd/lib/libwrtd.h
View file @
f8d5f0b1
...
...
@@ -189,6 +189,8 @@ extern void wrtd_sec_pico_to_ts(uint64_t sec, uint64_t pico,
* @{
*/
extern
const
char
*
wrtd_strlogging
(
enum
wrtd_log_level
lvl
);
enum
wrtd_log_level
wrtd_strlogging_to_level
(
char
*
log
);
extern
void
wrtd_strlogging_full
(
char
*
buf
,
uint32_t
log_level
);
extern
int
wrtd_log_read
(
struct
wrnc_hmq
*
hmq_log
,
struct
wrtd_log_entry
*
log
,
int
count
);
extern
void
wrtd_log_close
(
struct
wrnc_hmq
*
hmq
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment