aboutsummaryrefslogtreecommitdiff
path: root/include/cutils/alelog.h
blob: 294c7a9273d322bd4bc70abb0bf5dbd9cc29fa18 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
#if !defined(__ALE_H__)
#define __ALE_H__

#if defined(__cplusplus)
extern "C" {
#endif

#define LOGGER_ALE_MASK         0xf0

#define LOGGER_ALE_MSG_RAW      0x00
#define LOGGER_ALE_MSG_K        0x10
#define LOGGER_ALE_MSG_N        0x20
#define LOGGER_ALE_MSG_J        0x30
#define LOGGER_ALE_XMSG_K       0x40
#define LOGGER_ALE_XMSG_N       0x50
#define LOGGER_ALE_XMSG_J       0x60

#define LOGGER_ALE_MSG_SIZE     768

#define LOGGER_ALE_ARGS_MAX 16
struct ale_convert {
    const char *tag_str;
    const char *fmt_ptr;
    const char *file;
    int lineno;
    unsigned int hash;
    char params[LOGGER_ALE_ARGS_MAX];
};

int ale_log_output_binary(int prio, const char *tag, const void *payload, size_t len);

int ale_log_output(int bufid, int prio, const struct ale_convert *convert, ...);

#define ale_log_print(bufid, prio, tag, fmt, ...)			\
  ({									\
      if (__builtin_constant_p(tag) && __builtin_constant_p(fmt)) {     \
          static const struct ale_convert ____ale_rec____ =		\
	    {								\
                __builtin_constant_p(tag) ? tag : NULL,			\
                __builtin_constant_p(fmt) ? fmt : NULL,			\
                __FILE__,                                               \
                __builtin_constant_p(prio) ? prio : 0,                  \
                0,                                                      \
                "" };                                                   \
          ale_log_output(bufid, prio, &____ale_rec____, ##__VA_ARGS__);	\
      }                                                                 \
      else {                                                            \
          struct ale_convert ale =                                      \
              {tag, fmt, NULL,                                          \
               0, 0, ""};                                               \
          ale_log_output(bufid, prio, &ale, ##__VA_ARGS__);		\
      }                                                                 \
  })

#if defined(__cplusplus)
};
#endif

#endif