src/shared/queued_entry.c \
src/shared/logprint.c \
src/shared/parsers.c \
+ src/shared/logconfig.c \
+ src/shared/logcommon.c \
src/shared/translate_syslog.c
src_tests_kmsg_parser_CFLAGS = $(AM_CFLAGS)
src_tests_kmsg_parser_LDFLAGS = $(AM_LDFLAGS)
src/shared/queued_entry.c \
src/shared/logprint.c \
src/shared/parsers.c \
+ src/shared/logconfig.c \
+ src/shared/logcommon.c \
src/shared/translate_syslog.c
src_tests_syslog_parser_CFLAGS = $(AM_CFLAGS)
src_tests_syslog_parser_LDFLAGS = $(AM_LDFLAGS)
src_tests_pipe_message_SOURCES = src/tests/pipe_message.c \
src/shared/queued_entry.c \
src/shared/translate_syslog.c \
+ src/shared/logconfig.c \
+ src/shared/logcommon.c \
src/shared/parsers.c
src_tests_pipe_message_CFLAGS = $(AM_CFLAGS)
src_tests_pipe_message_LDFLAGS = $(AM_LDFLAGS)
log_priority filter_char_to_pri(char c);
char filter_pri_to_char(log_priority pri);
+enum sorting_order get_format_sorting(const log_format *format);
#ifdef __cplusplus
}
SORT_SENT_REAL,
SORT_RECV_MONO,
SORT_RECV_REAL,
- SORT_MAX
+ SORT_MAX,
+ SORT_DEFAULT,
};
void parse_pipe_message(struct pipe_logger_entry *ple, struct logger_entry *le, size_t msg_size);
void add_recv_timestamp(struct logger_entry *le);
enum sorting_order get_proper_sorting_order(bool is_pipe, log_id_t buf_id, enum sorting_order sort_by);
+enum sorting_order get_order_from_config(const struct log_config *conf);
+clockid_t get_proper_clock(enum sorting_order sort_by);
#ifdef __cplusplus
}
if (ret < 0)
return ret;
- enum sorting_order sort_by = SORT_SENT_MONO;
- const char * sort_str = log_config_get(&conf, "sort_by");
- if (sort_str) {
- if (!strcmp(sort_str, "sent_real"))
- sort_by = SORT_SENT_REAL;
- else if (!strcmp(sort_str, "recv_real"))
- sort_by = SORT_RECV_REAL;
- else if (!strcmp(sort_str, "recv_mono"))
- sort_by = SORT_RECV_MONO;
- }
+ const enum sorting_order sort_by = get_order_from_config(&conf);
const char * const backend = log_config_get(&conf, "backend");
if (!backend) {
return (char*)entry->msg + entry->tag_len + 1 /* NULL delimiter */;
}
+enum sorting_order get_format_sorting(const log_format *format)
+{
+ assert(format);
+
+ switch (format->format) {
+ case FORMAT_TAG:
+ case FORMAT_PROCESS:
+ case FORMAT_THREAD:
+ case FORMAT_RAW:
+ case FORMAT_BRIEF:
+ return SORT_DEFAULT;
+
+ case FORMAT_TIME:
+ case FORMAT_THREADTIME:
+ case FORMAT_KERNELTIME:
+ case FORMAT_LONG:
+ return SORT_SENT_MONO;
+
+ case FORMAT_RWTIME:
+ case FORMAT_RECV_REALTIME:
+ return SORT_RECV_REAL;
+
+ default:
+ assert(false);
+ }
+}
+
/**
* @brief Format log line
* @details Formats a log entry for direct printing
return sort_by;
}
+clockid_t get_proper_clock(enum sorting_order sort_by)
+{
+ switch (sort_by) {
+ case SORT_SENT_MONO:
+ case SORT_RECV_MONO:
+ return CLOCK_MONOTONIC;
+
+ case SORT_SENT_REAL:
+ case SORT_RECV_REAL:
+ return CLOCK_REALTIME;
+
+ default:
+ assert(false);
+ }
+}
+
+enum sorting_order get_order_from_config(const struct log_config *conf)
+{
+ enum sorting_order ret = SORT_RECV_MONO;
+
+ const char *const sort_str = log_config_get(conf, "sort_by");
+ if (sort_str) {
+ if (!strcmp(sort_str, "sent_real"))
+ ret = SORT_SENT_REAL;
+ else if (!strcmp(sort_str, "recv_real"))
+ ret = SORT_RECV_REAL;
+ else if (!strcmp(sort_str, "recv_mono"))
+ ret = SORT_RECV_MONO;
+ }
+
+ return ret;
+}
+
/**
* @}
*/