#include <sys/ioctl.h>
#define LOGGER_ENTRY_MAX_LEN (4*1024)
-#define LOGGER_ENTRY_MAX_PAYLOAD (LOGGER_ENTRY_MAX_LEN - sizeof(struct dlogutil_entry))
+#define LOGGER_ENTRY_MAX_PAYLOAD (LOGGER_ENTRY_MAX_LEN - sizeof(dlogutil_entry_s))
// These are taken from the kernel: ./drivers/staging/android/logger.h
#define __LOGGERIO 0xAE
bool (*has_log)(struct fd_info *fdi);
/// Extracts a buffered entry and relinquishes its ownership
- struct dlogutil_entry *(*extract_entry)(struct fd_info *fdi);
+ dlogutil_entry_s *(*extract_entry)(struct fd_info *fdi);
/// Returns a buffered entry without relinquishing ownership
- const struct dlogutil_entry *(*peek_entry)(const struct fd_info *fdi);
+ const dlogutil_entry_s *(*peek_entry)(const struct fd_info *fdi);
/// Transition into a state that allows reading and printing out logs
/// Return values > 0 mean everything went fine but we don't want to print
void fdi_array_free(struct fd_info ***arr);
bool fdi_has_log(struct fd_info *fdi);
int fdi_push_log(struct fd_info *fdi, struct sort_vector *logs, dlogutil_write_cb callback, void *userdata, dlogutil_filter_options_s *filter);
-struct dlogutil_entry *fdi_extract_entry(struct fd_info *fdi);
+dlogutil_entry_s *fdi_extract_entry(struct fd_info *fdi);
int fdi_read(struct fd_info *fdi);
int logfile_open(struct log_file *l_file);
int logfile_rotate_needed(struct log_file *l_file);
void logfile_do_rotate(struct log_file *file);
-int logfile_write_with_rotation(const struct dlogutil_entry *e, struct log_file *file, dlogutil_sorting_order_e sort_by);
+int logfile_write_with_rotation(const dlogutil_entry_s *e, struct log_file *file, dlogutil_sorting_order_e sort_by);
-typedef int dlogutil_write_cb(const struct dlogutil_entry *e, void *userdata);
+typedef int dlogutil_write_cb(const dlogutil_entry_s *e, void *userdata);
struct logfile_callback_data
{
struct log_file *file;
dlogutil_sorting_order_e sort_by;
};
-int logfile_callback(const struct dlogutil_entry *e, void *userdata);
+int logfile_callback(const dlogutil_entry_s *e, void *userdata);
#ifdef __cplusplus
}
* data (priority, tag, pid and tid), and false if it should not
*/
bool log_should_print_line(
- dlogutil_filter_options_s *p_filter, const struct dlogutil_entry *entry);
+ dlogutil_filter_options_s *p_filter, const dlogutil_entry_s *entry);
/**
* Returns pointer to log entry tag
*
* Finds the beginning of a log tag in entry's payload and returns it
*/
-const char* dlogutil_entry_tag(const struct dlogutil_entry *entry);
+const char* dlogutil_entry_tag(const dlogutil_entry_s *entry);
/**
* Returns pointer to log entry message
*
* Finds the beginning of a log message in entry's payload and returns it
*/
-const char* dlogutil_entry_msg(const struct dlogutil_entry *entry);
+const char* dlogutil_entry_msg(const dlogutil_entry_s *entry);
/**
* Formats a log message into a buffer
const struct log_format p_format,
char *defaultBuffer,
size_t defaultBufferSize,
- const struct dlogutil_entry *p_line,
+ const dlogutil_entry_s *p_line,
size_t *p_outLength);
/**
int log_print_log_line(
struct log_format p_format,
int fd,
- const struct dlogutil_entry *entry);
+ const dlogutil_entry_s *entry);
log_priority filter_char_to_pri(char c);
#define INVALID_SEC 0
#define INVALID_NSEC -1
-struct dlogutil_entry {
+typedef struct dlogutil_entry {
uint16_t len; /* length of the payload */
uint8_t priority; /* entry's priority*/
uint8_t padding;/* padding for alignment */
int32_t tag_len;
int32_t default_send_ts_type; /* default backend-dependant send time type */
char msg[]; /* the entry's payload */
-};
+} dlogutil_entry_s;
struct dlogutil_entry_with_msg {
- struct dlogutil_entry header;
+ dlogutil_entry_s header;
char msg[LOG_MAX_PAYLOAD_SIZE];
};
void create_pipe_message(void * buf, int prio, char const * tag, char const * msg);
int parse_kmsg_message(char *buffer, struct dlogutil_entry_with_msg *lem, int buffer_size);
-int parse_syslog_datagram(const char * buffer, int buffer_size, struct dlogutil_entry * le);
-void parse_androidlogger_message(struct android_logger_entry *ale, struct dlogutil_entry *le, size_t dgram_size);
-void parse_pipe_message(struct pipe_logger_entry *ple, struct dlogutil_entry *le, size_t msg_size);
+int parse_syslog_datagram(const char * buffer, int buffer_size, dlogutil_entry_s * le);
+void parse_androidlogger_message(struct android_logger_entry *ale, dlogutil_entry_s *le, size_t dgram_size);
+void parse_pipe_message(struct pipe_logger_entry *ple, dlogutil_entry_s *le, size_t msg_size);
#ifdef __cplusplus
}
#include <logconfig.h>
#include <queued_entry.h>
-void add_recv_timestamp(struct dlogutil_entry *le);
-void copy_recv_timestamp(struct dlogutil_entry *le);
-bool log_entry_is_earlier(const dlogutil_sorting_order_e sort_by, const struct dlogutil_entry *lhs, const struct dlogutil_entry *rhs);
-struct timespec dlogutil_entry_ts(const struct dlogutil_entry *le, dlogutil_sorting_order_e stamp_type);
+void add_recv_timestamp(dlogutil_entry_s *le);
+void copy_recv_timestamp(dlogutil_entry_s *le);
+bool log_entry_is_earlier(const dlogutil_sorting_order_e sort_by, const dlogutil_entry_s *lhs, const dlogutil_entry_s *rhs);
+struct timespec dlogutil_entry_ts(const dlogutil_entry_s *le, dlogutil_sorting_order_e stamp_type);
clockid_t get_proper_clock(dlogutil_sorting_order_e sort_by);
#endif /* _QUEUED_ENTRY_TIMESTAMP_H */
#define DEFAULT_SORT_BUFFER_SIZE 131072 // the size (in ENTRIES!) of the sorting buffer
struct sort_vector {
- struct dlogutil_entry **data;
+ dlogutil_entry_s **data;
int begin;
int end;
size_t size;
void sort_vector_init(struct sort_vector *logs);
int sort_vector_finalize(struct sort_vector *logs);
void sort_vector_free(struct sort_vector *logs);
-struct dlogutil_entry *sort_vector_back(struct sort_vector *logs);
+dlogutil_entry_s *sort_vector_back(struct sort_vector *logs);
int sort_vector_enlarge(struct sort_vector *logs);
int sort_vector_empty(struct sort_vector *logs);
int sort_vector_full(struct sort_vector *logs);
int sort_vector_used_size(struct sort_vector *logs);
void sort_vector_pop(struct sort_vector *logs);
void sort_vector_apply_config(struct sort_vector *logs, const struct log_config *config);
-int sort_vector_push(struct sort_vector *logs, struct dlogutil_entry *p, dlogutil_write_cb callback, void *userdata);
+int sort_vector_push(struct sort_vector *logs, dlogutil_entry_s *p, dlogutil_write_cb callback, void *userdata);
long sort_vector_time_span(struct sort_vector *logs);
int sort_vector_flush(struct sort_vector *logs, dlogutil_write_cb callback, void *userdata, bool force);
struct log_storage_entry *prev;
list_head readers;
// the field below must be the very last field in the struct, because it has variable size
- struct dlogutil_entry entry;
+ dlogutil_entry_s entry;
} log_storage_entry;
struct log_storage {
free(free_me);
}
-bool log_storage_add_new_entry(log_storage *storage, const struct dlogutil_entry *le)
+bool log_storage_add_new_entry(log_storage *storage, const dlogutil_entry_s *le)
{
assert(storage);
assert(le);
(NULL == reader->current && NULL != reader->storage->entries);
}
-const struct dlogutil_entry *log_storage_reader_get_new_entry(log_storage_reader *reader)
+const dlogutil_entry_s *log_storage_reader_get_new_entry(log_storage_reader *reader)
{
assert(reader);
- const struct dlogutil_entry *le = NULL;
+ const dlogutil_entry_s *le = NULL;
// storage is NULL if a dumping/one-shot reader has finished reading
if (NULL == reader->storage)
* @param[in] le The log entry which will be added.
* @return true on success, false on failure - on lack of memory.
*/
-bool log_storage_add_new_entry(log_storage *storage, const struct dlogutil_entry *le);
+bool log_storage_add_new_entry(log_storage *storage, const dlogutil_entry_s *le);
/**
* @brief This function makes all the log entries disappear. They vanish. Completely.
* @brief A type for callbacks that are called when there is last chance for a reader
* to handle a log entry.
*/
-typedef void (*log_storage_reader_callback)(const struct dlogutil_entry *le, void *user_data);
+typedef void (*log_storage_reader_callback)(const dlogutil_entry_s *le, void *user_data);
/**
* @brief This function creates a new reader.
* because this log entry may be deleted by the storage without warning. Precisely, when you put
* another log entry into the storage.
*/
-const struct dlogutil_entry *log_storage_reader_get_new_entry(log_storage_reader *reader);
+const dlogutil_entry_s *log_storage_reader_get_new_entry(log_storage_reader *reader);
/**
* @param[in] entry The entry to append
* @param[in] b The buffer whither to append
*/
-int buffer_append(const struct dlogutil_entry *entry, struct log_buffer *b)
+int buffer_append(const dlogutil_entry_s *entry, struct log_buffer *b)
{
if (!log_storage_add_new_entry(b->log_storage, entry))
return -ENOMEM;
printf("ERROR: not enough memory either, please check platform settings as the daemon is seriously resource-starved!\n");
}
-static int reader_print_out_single_log(struct reader *reader, const struct dlogutil_entry *dlogutil_entry)
+static int reader_print_out_single_log(struct reader *reader, const dlogutil_entry_s *dlogutil_entry)
{
assert(reader);
assert(reader->buf_ptr);
}
while (log_storage_reader_is_new_entry_available(reader->log_storage_reader)) {
- const struct dlogutil_entry* ple = (const struct dlogutil_entry *)log_storage_reader_get_new_entry(reader->log_storage_reader);
+ const dlogutil_entry_s* ple = (const dlogutil_entry_s *)log_storage_reader_get_new_entry(reader->log_storage_reader);
assert(ple);
return 0;
}
-void reader_notify_losing_log(const struct dlogutil_entry *le, void *reader_)
+void reader_notify_losing_log(const dlogutil_entry_s *le, void *reader_)
{
struct reader *reader = reader_;
assert(le);
assert(reader);
- reader_print_out_single_log(reader, (struct dlogutil_entry *)le);
+ reader_print_out_single_log(reader, (dlogutil_entry_s *)le);
}
/**
assert(logs);
assert(filter);
- struct dlogutil_entry *temp = fdi->ops->extract_entry(fdi);
+ dlogutil_entry_s *temp = fdi->ops->extract_entry(fdi);
if (!temp)
return -ENOMEM;
struct logger_priv_data {
int log_len;
- struct dlogutil_entry *entry;
+ dlogutil_entry_s *entry;
};
static int logger_ioctl(int fd, int ioctl_id)
return r;
}
-static struct dlogutil_entry *logger_extract_entry(struct fd_info *fdi)
+static dlogutil_entry_s *logger_extract_entry(struct fd_info *fdi)
{
assert(fdi);
struct logger_priv_data *lpd = (struct logger_priv_data *)fdi->priv_data;
assert(lpd);
- struct dlogutil_entry *const ret = lpd->entry;
+ dlogutil_entry_s *const ret = lpd->entry;
lpd->entry = NULL;
return ret;
}
-static const struct dlogutil_entry *logger_peek_entry(const struct fd_info *fdi)
+static const dlogutil_entry_s *logger_peek_entry(const struct fd_info *fdi)
{
assert(fdi);
const struct logger_priv_data *const lpd = (const struct logger_priv_data *)fdi->priv_data;
struct pipe_priv_data *ppd = (struct pipe_priv_data *)fdi->priv_data;
assert(ppd);
- const struct dlogutil_entry *const le = (const struct dlogutil_entry *)(ppd->buff + ppd->offset);
+ const dlogutil_entry_s *const le = (const dlogutil_entry_s *)(ppd->buff + ppd->offset);
return ppd->data_len >= sizeof le->len && ppd->data_len >= le->len;
}
-static struct dlogutil_entry *pipe_extract_entry(struct fd_info *fdi)
+static dlogutil_entry_s *pipe_extract_entry(struct fd_info *fdi)
{
assert(fdi);
struct pipe_priv_data *ppd = (struct pipe_priv_data *)fdi->priv_data;
assert(ppd);
- struct dlogutil_entry *const buf_le = (struct dlogutil_entry *)(ppd->buff + ppd->offset);
+ dlogutil_entry_s *const buf_le = (dlogutil_entry_s *)(ppd->buff + ppd->offset);
if (!buf_le->len)
return NULL;
- struct dlogutil_entry *const new_le = malloc(buf_le->len);
+ dlogutil_entry_s *const new_le = malloc(buf_le->len);
if (!new_le)
return NULL;
return new_le;
}
-static const struct dlogutil_entry *pipe_peek_entry(const struct fd_info *fdi)
+static const dlogutil_entry_s *pipe_peek_entry(const struct fd_info *fdi)
{
assert(fdi);
const struct pipe_priv_data *const ppd = (const struct pipe_priv_data *)fdi->priv_data;
assert(ppd);
- return (const struct dlogutil_entry *)(ppd->buff + ppd->offset);
+ return (const dlogutil_entry_s *)(ppd->buff + ppd->offset);
}
struct fd_ops ops_pipe = {
* @param[in] file The file to write to
* @returns 0 if log was successfully written, else 1
*/
-int logfile_write_with_rotation(const struct dlogutil_entry *e, struct log_file *file, dlogutil_sorting_order_e sort_by)
+int logfile_write_with_rotation(const dlogutil_entry_s *e, struct log_file *file, dlogutil_sorting_order_e sort_by)
{
if (file->colors_auto)
file->format.color = file->isatty;
return 0;
}
-int logfile_callback(const struct dlogutil_entry *e, void *userdata)
+int logfile_callback(const dlogutil_entry_s *e, void *userdata)
{
struct logfile_callback_data *data = userdata;
return logfile_write_with_rotation(e, data->file, data->sort_by);
* @param[in] entry The log entry to filter
* @return True if the line should be printed, else false
*/
-bool log_should_print_line(dlogutil_filter_options_s *p_filter, const struct dlogutil_entry *entry)
+bool log_should_print_line(dlogutil_filter_options_s *p_filter, const dlogutil_entry_s *entry)
{
assert(p_filter);
assert(entry);
* @param[in] entry The log entry
* @return Pointer to log tag
*/
-const char* dlogutil_entry_tag(const struct dlogutil_entry *entry)
+const char* dlogutil_entry_tag(const dlogutil_entry_s *entry)
{
assert(entry);
- if (entry->len - (int) sizeof(struct dlogutil_entry) < 2)
+ if (entry->len - (int) sizeof(dlogutil_entry_s) < 2)
return NULL;
if (((const char *)entry)[entry->len - 1] != '\0')
return NULL;
* @param[in] entry The log entry
* @return Pointer to log message
*/
-const char* dlogutil_entry_msg(const struct dlogutil_entry *entry)
+const char* dlogutil_entry_msg(const dlogutil_entry_s *entry)
{
assert(entry);
- if (entry->len - (int) sizeof(struct dlogutil_entry) < 2)
+ if (entry->len - (int) sizeof(dlogutil_entry_s) < 2)
return NULL;
if (((const char *)entry)[entry->len - 1] != '\0')
return NULL;
char *log_format_json(
char *default_buffer,
size_t default_buffer_size,
- const struct dlogutil_entry *entry,
+ const dlogutil_entry_s *entry,
size_t *p_outLength,
const char *tag,
const char *msg)
TS_RECV,
};
-static bool entry_get_ts_inner(const struct dlogutil_entry *entry, bool sent, bool mono, struct timespec *target)
+static bool entry_get_ts_inner(const dlogutil_entry_s *entry, bool sent, bool mono, struct timespec *target)
{
int sec = sent
? (mono ? entry->sec_sent_mono : entry->sec_sent_real)
return true;
}
-struct timespec entry_get_ts(const struct dlogutil_entry *entry, const log_print_format format, enum ts_type type)
+struct timespec entry_get_ts(const dlogutil_entry_s *entry, const log_print_format format, enum ts_type type)
{
/* The returned timestamp should match the format (as in, the printf specifier) used below.
* In particular, monotonic timestamps should be the ones represented by the 'raw' (%u)
const struct log_format p_format,
char *defaultBuffer,
size_t defaultBufferSize,
- const struct dlogutil_entry *entry,
+ const dlogutil_entry_s *entry,
size_t *p_outLength)
{
#if defined(HAVE_LOCALTIME_R)
char *p;
size_t bufferSize;
const char *pm;
- int message_len = entry->len - sizeof(struct dlogutil_entry) - entry->tag_len - 2 /* tag and msg delimiters */;
+ int message_len = entry->len - sizeof(dlogutil_entry_s) - entry->tag_len - 2 /* tag and msg delimiters */;
const char *const pre_color_prefix = get_pre_color((log_priority)entry->priority, colorPrefix && p_format.color);
const char *const pre_color_suffix = get_pre_color((log_priority)entry->priority, colorSuffix && p_format.color);
int log_print_log_line(
struct log_format p_format,
int fd,
- const struct dlogutil_entry *entry)
+ const dlogutil_entry_s *entry)
{
int ret;
char defaultBuffer[512];
if (!fdi || !fdi->ops->has_log(fdi))
continue;
- const struct dlogutil_entry *const le = fdi->ops->peek_entry(fdi);
+ const dlogutil_entry_s *const le = fdi->ops->peek_entry(fdi);
struct timespec current_ts = dlogutil_entry_ts(le, sort_by);
if (best_fdi && ((current_ts.tv_sec > best_ts.tv_sec) || (current_ts.tv_sec == best_ts.tv_sec && current_ts.tv_nsec > best_ts.tv_nsec)))
lem->header.len = lem->header.tag_len + 1; // plus NULL delimiter
lem->header.len += 1 + snprintf(lem->msg + lem->header.len, sizeof lem->msg - 1 - lem->header.len, "%s", msg_begin);
- lem->header.len += sizeof(struct dlogutil_entry);
+ lem->header.len += sizeof(dlogutil_entry_s);
lem->header.padding = 0;
return 0;
}
#ifdef USE_ANDROID_MONOTONIC
-static void parse_android_logger_footer(struct android_logger_entry *ale, struct dlogutil_entry *le, size_t *payload_size)
+static void parse_android_logger_footer(struct android_logger_entry *ale, dlogutil_entry_s *le, size_t *payload_size)
{
assert(ale);
assert(le);
* @param[out] le Target structure to contain the log
* @param[in] size The size of the datagram
*/
-void parse_androidlogger_message(struct android_logger_entry *ale, struct dlogutil_entry *le, size_t dgram_size)
+void parse_androidlogger_message(struct android_logger_entry *ale, dlogutil_entry_s *le, size_t dgram_size)
{
size_t payload_size = dgram_size - sizeof *ale;
assert(payload_size > 0);
le->default_send_ts_type = LOGGER_ENTRY_REALTIME;
}
-void parse_pipe_message(struct pipe_logger_entry *ple, struct dlogutil_entry *le, size_t msg_size)
+void parse_pipe_message(struct pipe_logger_entry *ple, dlogutil_entry_s *le, size_t msg_size)
{
size_t payload_size = msg_size - sizeof *ple;
assert(payload_size <= LOG_MAX_PAYLOAD_SIZE);
* @param[in] pid Process ID
* @param msg Message
*/
-static void construct_logger_entry_from_syslog(struct dlogutil_entry *le, int priority, const char *tag, struct tm *timestamp, int pid, const char *msg)
+static void construct_logger_entry_from_syslog(dlogutil_entry_s *le, int priority, const char *tag, struct tm *timestamp, int pid, const char *msg)
{
assert(le);
assert(tag);
le->tag_len = strlen(tag);
const int msg_len = strlen(msg) + 1;
- le->len = sizeof(struct dlogutil_entry) + le->tag_len + 1 + msg_len;
+ le->len = sizeof(dlogutil_entry_s) + le->tag_len + 1 + msg_len;
le->pid = pid;
le->tid = 0; // could be set to PID but this way it's explicit the TID is not known
le->sec_sent_real = mktime(timestamp);
* @param[out] le The logger entry to fill
* @return 0 on failure, 1 on success
*/
-int parse_syslog_datagram(const char *buffer, int buffer_size, struct dlogutil_entry * le)
+int parse_syslog_datagram(const char *buffer, int buffer_size, dlogutil_entry_s * le)
{
int fac_prio = -1, pid = 0;
struct tm timestamp;
* @details Add a timestamp describing reception time.
* @param[in/out] le The logger entry to stamp time on.
*/
-void add_recv_timestamp(struct dlogutil_entry *le)
+void add_recv_timestamp(dlogutil_entry_s *le)
{
struct timespec ts;
* @details Replicates recv timestamp from sent timestamp where adding a new one would not make sense
* @param[in/out] le The logger entry to replicate the time stamp for.
*/
-void copy_recv_timestamp(struct dlogutil_entry *le)
+void copy_recv_timestamp(dlogutil_entry_s *le)
{
le->sec_recv_mono = le->sec_sent_mono;
le->nsec_recv_mono = le->nsec_sent_mono;
le->nsec_recv_real = le->nsec_sent_real;
}
-bool log_entry_is_earlier(const dlogutil_sorting_order_e sort_by, const struct dlogutil_entry *lhs, const struct dlogutil_entry *rhs)
+bool log_entry_is_earlier(const dlogutil_sorting_order_e sort_by, const dlogutil_entry_s *lhs, const dlogutil_entry_s *rhs)
{
assert(lhs);
assert(rhs);
return l_sec < r_sec || (l_sec == r_sec && l_nsec < r_nsec);
}
-struct timespec dlogutil_entry_ts(const struct dlogutil_entry *le, dlogutil_sorting_order_e stamp_type)
+struct timespec dlogutil_entry_ts(const dlogutil_entry_s *le, dlogutil_sorting_order_e stamp_type)
{
assert(le);
if (!IS_VECTOR_SIZE_SORTABLE(logs->size))
return 1;
- logs->data = (struct dlogutil_entry **)calloc(logs->size, sizeof(struct dlogutil_entry *));
+ logs->data = (dlogutil_entry_s **)calloc(logs->size, sizeof(dlogutil_entry_s *));
return logs->data != NULL;
}
logs->timeout = log_config_get_int(config, "util_sorting_time_window", logs->timeout);
}
-struct dlogutil_entry *sort_vector_back(struct sort_vector *logs)
+dlogutil_entry_s *sort_vector_back(struct sort_vector *logs)
{
return logs->data[logs->begin];
}
* @param[in] logs Log sorting vector
* @return 0 on success, -errno on failure
*/
-int sort_vector_push(struct sort_vector *logs, struct dlogutil_entry *p, dlogutil_write_cb callback, void *userdata)
+int sort_vector_push(struct sort_vector *logs, dlogutil_entry_s *p, dlogutil_write_cb callback, void *userdata)
{
assert(logs);
assert(logs->data);
* always all of the entries we receive have the same timestamps. Also, in such cases
* correct sorting is impossible anyway.
*/
- struct dlogutil_entry *const e = logs->data[(i ?: logs->size) - 1];
+ dlogutil_entry_s *const e = logs->data[(i ?: logs->size) - 1];
if (!log_entry_is_earlier(logs->sort_by, p, e))
break;
logs->data[i] = e;
* @param[out] callback_ret Return value of the callback if it has been called
* @return bool whether the log was old enough
*/
-bool process_log(const struct dlogutil_entry *e, struct timespec reference_ts, dlogutil_sorting_order_e stamp_type, dlogutil_write_cb callback, void *userdata, long timeout, int *callback_ret)
+bool process_log(const dlogutil_entry_s *e, struct timespec reference_ts, dlogutil_sorting_order_e stamp_type, dlogutil_write_cb callback, void *userdata, long timeout, int *callback_ret)
{
assert(e);
assert(callback_ret);
}
static bool sv_flushed;
-int callback(const struct dlogutil_entry *entry, void *userdata)
+int callback(const dlogutil_entry_s *entry, void *userdata)
{
- assert(entry == (struct dlogutil_entry *) 0xBADFEEL);
+ assert(entry == (dlogutil_entry_s *) 0xBADFEEL);
assert(userdata == (struct log_file *) 0xDEFACED);
sv_flushed = true;
static bool sv_pushed;
static int sv_push_retval;
-int __wrap_sort_vector_push(struct sort_vector *logs, struct dlogutil_entry *p, dlogutil_write_cb comp_callback, void *userdata)
+int __wrap_sort_vector_push(struct sort_vector *logs, dlogutil_entry_s *p, dlogutil_write_cb comp_callback, void *userdata)
{
- assert(p == (struct dlogutil_entry *) 0xBADFEEL);
+ assert(p == (dlogutil_entry_s *) 0xBADFEEL);
assert(comp_callback == callback);
assert(userdata == (struct log_file *) 0xDEFACED);
struct fd_info G_fdi;
static bool fail_extract;
-struct dlogutil_entry *test_extract(struct fd_info *fdi)
+dlogutil_entry_s *test_extract(struct fd_info *fdi)
{
assert(fdi == &G_fdi);
- return fail_extract ? NULL : (struct dlogutil_entry *) 0xBADFEEL;
+ return fail_extract ? NULL : (dlogutil_entry_s *) 0xBADFEEL;
}
-struct timespec __wrap_dlogutil_entry_ts(const struct dlogutil_entry *le, dlogutil_sorting_order_e stamp_type)
+struct timespec __wrap_dlogutil_entry_ts(const dlogutil_entry_s *le, dlogutil_sorting_order_e stamp_type)
{
- assert(le == (struct dlogutil_entry *)0xBADFEEL);
+ assert(le == (dlogutil_entry_s *)0xBADFEEL);
return (struct timespec) {
.tv_sec = 1,
.tv_nsec = 1,
}
static bool should_print_line = true;
-bool __wrap_log_should_print_line(dlogutil_filter_options_s *p_filter, const struct dlogutil_entry *entry)
+bool __wrap_log_should_print_line(dlogutil_filter_options_s *p_filter, const dlogutil_entry_s *entry)
{
assert(p_filter == (dlogutil_filter_options_s *)404);
- assert(entry == (struct dlogutil_entry *)0xBADFEEL);
+ assert(entry == (dlogutil_entry_s *)0xBADFEEL);
return should_print_line;
}
assert(false);
}
-void __wrap_parse_androidlogger_message(struct android_logger_entry *ale, struct dlogutil_entry *le, size_t dgram_size) { }
-void __wrap_copy_recv_timestamp(struct dlogutil_entry *le) { }
+void __wrap_parse_androidlogger_message(struct android_logger_entry *ale, dlogutil_entry_s *le, size_t dgram_size) { }
+void __wrap_copy_recv_timestamp(dlogutil_entry_s *le) { }
static bool use_real_close;
int __real_close(int fd);
if (!fail_malloc && i < NELEMS(READS) && READS[i] > sizeof(struct android_logger_entry)) {
assert(ops_logger.has_log(&fdi));
assert(-EAGAIN == ops_logger.read(&fdi));
- const struct dlogutil_entry *const le = ops_logger.peek_entry(&fdi);
+ const dlogutil_entry_s *const le = ops_logger.peek_entry(&fdi);
assert(le);
assert(le == ops_logger.peek_entry(&fdi));
assert(le == ops_logger.extract_entry(&fdi));
- free((struct dlogutil_entry *) le);
+ free((dlogutil_entry_s *) le);
}
fail_malloc = 0;
assert(!ops_logger.has_log(&fdi));
assert(ops_pipe.read(&info) == -EIO);
read_errno = 0;
- read_datalen = sizeof(struct dlogutil_entry) + 4;
- struct dlogutil_entry *ent = read_data = malloc(read_datalen);
+ read_datalen = sizeof(dlogutil_entry_s) + 4;
+ dlogutil_entry_s *ent = read_data = malloc(read_datalen);
assert(ent);
read_pos = 0;
ent->len = read_datalen;
assert(!ops_pipe.extract_entry(&info));
malloc_fail = false;
- struct dlogutil_entry *ent2 = ops_pipe.extract_entry(&info);
+ dlogutil_entry_s *ent2 = ops_pipe.extract_entry(&info);
assert(!memcmp(ent, ent2, ent->len));
__real_free(ent2);
}
__real_free(ent);
- read_datalen = sizeof(struct dlogutil_entry);
+ read_datalen = sizeof(dlogutil_entry_s);
read_data = calloc(1, read_datalen);
read_pos = 0;
assert(ops_pipe.read(&info) == read_datalen);
entry.header.pid = 0;
entry.header.tid = tid;
entry.header.priority = DLOG_DEBUG; // priority, for unmatched entries that have to face the global filter
- entry.header.len = sizeof(struct dlogutil_entry) + 2;
+ entry.header.len = sizeof(dlogutil_entry_s) + 2;
if (expected != log_should_print_line(p_filter, &entry.header)) {
printf("Check in line %d for tid %lu failed to return %d \n", line, tid,
entry.header.tid = 0;
entry.header.pid = pid;
entry.header.priority = DLOG_DEBUG; // priority, for unmatched entries that have to face the global filter
- entry.header.len = sizeof(struct dlogutil_entry) + 2;
+ entry.header.len = sizeof(dlogutil_entry_s) + 2;
if (expected != log_should_print_line(p_filter, &entry.header)) {
printf("Check in line %d for pid %d failed to return %d \n", line, pid,
entry.header.priority = priority;
strncpy(entry.msg, tag, strlen(tag) + 1);
entry.msg[strlen(tag) + 1] = '\0'; // second NULL terminator: empty message
- entry.header.len = sizeof(struct dlogutil_entry) + strlen(tag) + 2;
+ entry.header.len = sizeof(dlogutil_entry_s) + strlen(tag) + 2;
if (expected != log_should_print_line(p_filter, &entry.header)) {
printf("Check in line %d for tag %s and priority %c failed to return %d \n", line, tag,
strncpy(entry.msg, "crap", taglen);
entry.msg[taglen] = '\0'; /* tag delimiter */
entry.msg[taglen + 1] = '\0'; /* empty msg */
- entry.header.len = sizeof(struct dlogutil_entry) + taglen + 2;
+ entry.header.len = sizeof(dlogutil_entry_s) + taglen + 2;
assert(log_should_print_line(p_filter, &entry.header));
result += check_print_line_tag(__LINE__, p_filter, "crap", verbose | debug | info | warn | error | fatal);
lem.header.len = lem.header.tag_len + 1; // plus NULL delimiter
lem.header.len += 1 + snprintf(lem.msg + lem.header.len, sizeof lem.msg - 1 - lem.header.len, "%s", "Some message.");
- lem.header.len += sizeof(struct dlogutil_entry);
+ lem.header.len += sizeof(dlogutil_entry_s);
lem.header.padding = 0;
assert_entry("1,234,56789,-;Some message.\n _SOME_IRRELEVANT_TAG=BLA\n", &lem);
return -1;
}
-struct timespec __wrap_dlogutil_entry_ts(const struct dlogutil_entry *le, dlogutil_sorting_order_e stamp_type)
+struct timespec __wrap_dlogutil_entry_ts(const dlogutil_entry_s *le, dlogutil_sorting_order_e stamp_type)
{
assert(stamp_type == DLOGUTIL_SORT_SENT_MONO);
- assert(le == (struct dlogutil_entry *) 0xBA5EBALL);
+ assert(le == (dlogutil_entry_s *) 0xBA5EBALL);
return (struct timespec) {
.tv_sec = 3333,
.tv_nsec = 9999,
};
}
-char *__wrap_dlogutil_entry_tag(const struct dlogutil_entry *entry)
+char *__wrap_dlogutil_entry_tag(const dlogutil_entry_s *entry)
{
- assert(entry == (struct dlogutil_entry *) 0xBA5EBALL);
+ assert(entry == (dlogutil_entry_s *) 0xBA5EBALL);
return "";
}
return __real_memcpy(dest, src, n);
assert(src == (void *) 0xBA5EBALL);
- assert(n == sizeof(struct dlogutil_entry));
+ assert(n == sizeof(dlogutil_entry_s));
return dest;
}
static int log_print_log_line_ret;
static bool log_print_log_line_correct_color;
-int __wrap_log_print_log_line(struct log_format p_format, int fd, const struct dlogutil_entry *entry)
+int __wrap_log_print_log_line(struct log_format p_format, int fd, const dlogutil_entry_s *entry)
{
assert(fd == 0xFD);
assert(p_format.color == log_print_log_line_correct_color);
isatty_ret = lf.isatty = false;
log_print_log_line_ret = -1;
log_print_log_line_correct_color = false;
- assert(logfile_write_with_rotation((struct dlogutil_entry *) 0xBA5EBALL, &lf, DLOGUTIL_SORT_SENT_MONO));
+ assert(logfile_write_with_rotation((dlogutil_entry_s *) 0xBA5EBALL, &lf, DLOGUTIL_SORT_SENT_MONO));
assert(lf.prev_sec == 4444);
assert(lf.prev_nsec == 6666);
log_print_log_line_ret = 1;
fail_snprintf = true;
- assert(!logfile_write_with_rotation((struct dlogutil_entry *) 0xBA5EBALL, &lf, DLOGUTIL_SORT_SENT_MONO));
+ assert(!logfile_write_with_rotation((dlogutil_entry_s *) 0xBA5EBALL, &lf, DLOGUTIL_SORT_SENT_MONO));
assert(lf.prev_sec == 3333);
assert(lf.prev_nsec == 9999);
lf.colors_auto = true;
- assert(!logfile_write_with_rotation((struct dlogutil_entry *) 0xBA5EBALL, &lf, DLOGUTIL_SORT_SENT_MONO));
+ assert(!logfile_write_with_rotation((dlogutil_entry_s *) 0xBA5EBALL, &lf, DLOGUTIL_SORT_SENT_MONO));
assert(lf.prev_sec == 3333);
assert(lf.prev_nsec == 9999);
isatty_ret = lf.isatty = true;
lf.colors_auto = false;
- assert(!logfile_write_with_rotation((struct dlogutil_entry *) 0xBA5EBALL, &lf, DLOGUTIL_SORT_SENT_MONO));
+ assert(!logfile_write_with_rotation((dlogutil_entry_s *) 0xBA5EBALL, &lf, DLOGUTIL_SORT_SENT_MONO));
assert(lf.prev_sec == 3333);
assert(lf.prev_nsec == 9999);
lf.colors_auto = true;
log_print_log_line_correct_color = true;
- assert(!logfile_write_with_rotation((struct dlogutil_entry *) 0xBA5EBALL, &lf, DLOGUTIL_SORT_SENT_MONO));
+ assert(!logfile_write_with_rotation((dlogutil_entry_s *) 0xBA5EBALL, &lf, DLOGUTIL_SORT_SENT_MONO));
assert(lf.prev_sec == 3333);
assert(lf.prev_nsec == 9999);
isatty_ret = lf.isatty = false;
lf.format.color = true;
lf.colors_auto = false;
- assert(!logfile_write_with_rotation((struct dlogutil_entry *) 0xBA5EBALL, &lf, DLOGUTIL_SORT_SENT_MONO));
+ assert(!logfile_write_with_rotation((dlogutil_entry_s *) 0xBA5EBALL, &lf, DLOGUTIL_SORT_SENT_MONO));
assert(lf.prev_sec == 3333);
assert(lf.prev_nsec == 9999);
lf.colors_auto = true;
log_print_log_line_correct_color = false;
- assert(!logfile_write_with_rotation((struct dlogutil_entry *) 0xBA5EBALL, &lf, DLOGUTIL_SORT_SENT_MONO));
+ assert(!logfile_write_with_rotation((dlogutil_entry_s *) 0xBA5EBALL, &lf, DLOGUTIL_SORT_SENT_MONO));
assert(lf.prev_sec == 3333);
assert(lf.prev_nsec == 9999);
fail_snprintf = false;
- assert(!logfile_write_with_rotation((struct dlogutil_entry *) 0xBA5EBALL, &lf, DLOGUTIL_SORT_SENT_MONO));
+ assert(!logfile_write_with_rotation((dlogutil_entry_s *) 0xBA5EBALL, &lf, DLOGUTIL_SORT_SENT_MONO));
custom_memcpy = false;
logfile_free(&lf);
int reader_ms_since(const struct reader *reader, struct timespec *ts);
int reader_should_buffer(struct reader *reader, const struct buf_params *buf_params, struct timespec now);
void reader_free(struct reader* reader);
-int buffer_append(const struct dlogutil_entry *entry, struct log_buffer *b);
+int buffer_append(const dlogutil_entry_s *entry, struct log_buffer *b);
int reader_init_for_pipe(struct reader *reader, const char *buf_name, struct logger *server);
int reader_init_for_logger(struct reader *reader, const char *buf_name, struct logger *server);
int print_out_logs(struct reader *reader);
int remove_fd_entity(struct logger *logger, struct fd_entity *fd_entity);
void writer_close_fd(struct logger* server, struct writer* wr);
int add_buffer_reader(struct log_buffer *buffer, struct reader *reader);
-void reader_notify_losing_log(const struct dlogutil_entry *le, void *reader_);
+void reader_notify_losing_log(const dlogutil_entry_s *le, void *reader_);
bool fail_dlog_group_server = false;
int __wrap_getgrnam_r(const char *name, struct group *grp,
}
bool add_new_entry_result = true;
-bool __wrap_log_storage_add_new_entry(log_storage *storage, const struct dlogutil_entry *le)
+bool __wrap_log_storage_add_new_entry(log_storage *storage, const dlogutil_entry_s *le)
{
assert(storage == (log_storage *)570);
- assert(le == (struct dlogutil_entry *)0xE);
+ assert(le == (dlogutil_entry_s *)0xE);
return add_new_entry_result;
}
};
add_new_entry_result = false;
- assert(buffer_append((struct dlogutil_entry *)0xE, &adder) == -ENOMEM);
+ assert(buffer_append((dlogutil_entry_s *)0xE, &adder) == -ENOMEM);
add_new_entry_result = true;
- assert(buffer_append((struct dlogutil_entry *)0xE, &adder) == 0);
+ assert(buffer_append((dlogutil_entry_s *)0xE, &adder) == 0);
struct reader reader3 = {};
struct logger server = {
TS_RECV,
};
const char *json_priority_name(log_priority prio);
-struct timespec entry_get_ts(const struct dlogutil_entry *entry, const log_print_format format, enum ts_type type);
-char *log_format_json(char *default_buffer, size_t default_buffer_size, const struct dlogutil_entry *entry, size_t *p_outLength, char *tag, char *msg);
+struct timespec entry_get_ts(const dlogutil_entry_s *entry, const log_print_format format, enum ts_type type);
+char *log_format_json(char *default_buffer, size_t default_buffer_size, const dlogutil_entry_s *entry, size_t *p_outLength, char *tag, char *msg);
void check_json()
{
// TODO: Failure testing
assert(!strcmp(json_priority_name(123), "unknown"));
char data[] = "tag\0important message";
- struct dlogutil_entry *ent = calloc(1, sizeof(struct dlogutil_entry) + sizeof data);
+ dlogutil_entry_s *ent = calloc(1, sizeof(dlogutil_entry_s) + sizeof data);
assert(ent);
ent->len = sizeof data;
ent->tag_len = 3;
void check_invalid_input()
{
- const struct dlogutil_entry entry = { .len = 1 };
+ const dlogutil_entry_s entry = { .len = 1 };
assert(!dlogutil_entry_msg(&entry));
assert(!dlogutil_entry_tag(&entry));
#include <sort_vector.h>
#include <fd_info.h>
-bool process_log(const struct dlogutil_entry *e, struct timespec reference_ts, dlogutil_sorting_order_e stamp_type, dlogutil_write_cb callback, void *userdata, long timeout, int *callback_ret);
+bool process_log(const dlogutil_entry_s *e, struct timespec reference_ts, dlogutil_sorting_order_e stamp_type, dlogutil_write_cb callback, void *userdata, long timeout, int *callback_ret);
struct fd_info *find_earliest_log(struct fd_info **data_fds, int fd_count, dlogutil_sorting_order_e sort_by);
int put_logs_into_vector(struct fd_info **data_fds, int fd_count, int nfds, struct sort_vector *logs, dlogutil_write_cb callback, void *userdata, dlogutil_filter_options_s *filter);
int validate_buffers(int *enabled_buffers);
int written_logs = 0;
bool free_entries = false;
int callback_ret = 0;
-int callback(const struct dlogutil_entry *entry, void *userdata)
+int callback(const dlogutil_entry_s *entry, void *userdata)
{
assert(userdata == (void *)0xDDD);
return 0;
}
-bool __wrap_log_should_print_line(dlogutil_filter_options_s *p_filter, const struct dlogutil_entry *entry)
+bool __wrap_log_should_print_line(dlogutil_filter_options_s *p_filter, const dlogutil_entry_s *entry)
{
return true;
}
struct fdi_internal
{
bool has_log;
- const struct dlogutil_entry *ent;
+ const dlogutil_entry_s *ent;
};
bool test_has_log(struct fd_info *fdi)
return ii->has_log;
}
-const struct dlogutil_entry *test_peek_entry(const struct fd_info *fdi)
+const dlogutil_entry_s *test_peek_entry(const struct fd_info *fdi)
{
struct fdi_internal *ii = fdi->priv_data;
return ii->ent;
assert(filter == (dlogutil_filter_options_s *)0xEEE);
if (fdi_push_log_ret != 0)
return fdi_push_log_ret;
- struct dlogutil_entry *ent = calloc(1, sizeof(struct dlogutil_entry));
+ dlogutil_entry_s *ent = calloc(1, sizeof(dlogutil_entry_s));
assert(ent);
- memcpy(ent, fdi->ops->peek_entry(fdi), sizeof(struct dlogutil_entry));
+ memcpy(ent, fdi->ops->peek_entry(fdi), sizeof(dlogutil_entry_s));
struct fdi_internal *ii = fdi->priv_data;
ii->has_log = false;
return sort_vector_push(logs, ent, callback, userdata);
int main()
{
- struct dlogutil_entry ent = {
+ dlogutil_entry_s ent = {
.sec_sent_mono = 0,
.nsec_sent_mono = 900000000,
.sec_sent_real = 0,
assert(written_logs == 3 && sort_vector_used_size(&sv) == 0);
for (int i = 0; i < 10; ++i) {
- struct dlogutil_entry *ent2 = calloc(1, sizeof(struct dlogutil_entry));
+ dlogutil_entry_s *ent2 = calloc(1, sizeof(dlogutil_entry_s));
assert(ent2);
ent2->sec_sent_mono = 1;
ent2->nsec_sent_mono = (79 + i) * 10000000;
sort_vector_flush(&sv, callback, (struct log_file *)0xDDD, false);
assert(written_logs == 9 && sort_vector_used_size(&sv) == 4);
- struct dlogutil_entry *ent3 = calloc(1, sizeof(struct dlogutil_entry));
+ dlogutil_entry_s *ent3 = calloc(1, sizeof(dlogutil_entry_s));
assert(ent3);
ent3->sec_sent_mono = 0;
ent3->nsec_sent_mono = 999999999;
struct fd_info fd_stor[10] = {};
struct fdi_internal ii_stor[10] = {};
- struct dlogutil_entry ent_stor[10 - 3] = {};
+ dlogutil_entry_s ent_stor[10 - 3] = {};
for (int i = 0; i < 10; ++i) {
if (i < 3)
ii_stor[i].has_log = false;
while (!sort_vector_empty(&sv))
sort_vector_pop(&sv);
- struct dlogutil_entry *ent_future = calloc(1, sizeof(struct dlogutil_entry));
+ dlogutil_entry_s *ent_future = calloc(1, sizeof(dlogutil_entry_s));
assert(ent_future);
ent_future->sec_sent_mono = 2;
ent_future->nsec_sent_mono = 0;
char tag[] = "TEST_TAG";
char msg[] = "Test message with a newline \n and some special characters \e[31m in colour";
struct pipe_logger_entry *ple = alloca(LOG_MAX_PAYLOAD_SIZE + sizeof *ple);
- struct dlogutil_entry *le = alloca(LOG_MAX_PAYLOAD_SIZE + sizeof *le);
+ dlogutil_entry_s *le = alloca(LOG_MAX_PAYLOAD_SIZE + sizeof *le);
struct timespec ts_pre, ts_post;
clock_gettime(CLOCK_MONOTONIC, &ts_pre);
}
struct timespec ts;
- struct dlogutil_entry le = {
+ dlogutil_entry_s le = {
.sec_sent_mono = 1,
.nsec_sent_mono = 2,
.sec_sent_real = 3,
size_t total_flushed;
int callback_ret = 0;
-int callback(const struct dlogutil_entry *e, void *userdata)
+int callback(const dlogutil_entry_s *e, void *userdata)
{
assert(userdata == (void *)0xDA7A);
total_flushed += (size_t) e;
return callback_ret;
}
-bool __wrap_log_entry_is_earlier(const dlogutil_sorting_order_e sort_by, const struct dlogutil_entry *lhs, const struct dlogutil_entry *rhs)
+bool __wrap_log_entry_is_earlier(const dlogutil_sorting_order_e sort_by, const dlogutil_entry_s *lhs, const dlogutil_entry_s *rhs)
{
return lhs < rhs;
}
struct log_file lf;
memset(&lf, 0, sizeof(struct log_file));
-#define ADD(x) assert(sort_vector_push(&sv, (struct dlogutil_entry *) x, callback, (void *)0xDA7A) == callback_ret)
+#define ADD(x) assert(sort_vector_push(&sv, (dlogutil_entry_s *) x, callback, (void *)0xDA7A) == callback_ret)
#define POP(x) \
free_total = 0; \
sort_vector_pop(&sv); \
* └──┴──┴──┴──┴──┴──┴──┘ */
assert(!sort_vector_empty(&sv));
assert(!sort_vector_full(&sv));
- assert((struct dlogutil_entry *) 12 == sort_vector_back(&sv));
+ assert((dlogutil_entry_s *) 12 == sort_vector_back(&sv));
assert(5 == sort_vector_used_size(&sv));
POP(12);
* └──┴──┴──┴──┴──┴──┴──┘ */
assert(!sort_vector_empty(&sv));
assert(sort_vector_full(&sv)); // the empty slot is reserved for operations
- assert((struct dlogutil_entry *) 7 == sort_vector_back(&sv));
+ assert((dlogutil_entry_s *) 7 == sort_vector_back(&sv));
assert(6 == sort_vector_used_size(&sv));
ADD(24);
* └──┴──┴──┴──┴──┴──┴──┘ */
assert(!sort_vector_empty(&sv));
assert(sort_vector_full(&sv));
- assert((struct dlogutil_entry *) 17 == sort_vector_back(&sv));
+ assert((dlogutil_entry_s *) 17 == sort_vector_back(&sv));
assert(6 == sort_vector_used_size(&sv));
POP(17);
* └──┴──┴──┴──┴──┴──┴──┘ */
assert(!sort_vector_empty(&sv));
assert(sort_vector_full(&sv));
- assert((struct dlogutil_entry *) 20 == sort_vector_back(&sv));
+ assert((dlogutil_entry_s *) 20 == sort_vector_back(&sv));
assert(6 == sort_vector_used_size(&sv));
callback_ret = 13;
* └──┴──┴──┴──┴──┴──┴──┘ */
assert(!sort_vector_empty(&sv));
assert(sort_vector_full(&sv));
- assert((struct dlogutil_entry *) 20 == sort_vector_back(&sv));
+ assert((dlogutil_entry_s *) 20 == sort_vector_back(&sv));
assert(6 == sort_vector_used_size(&sv));
callback_ret = 0;
#undef ADD
#undef POP
- assert(sv.data[0] == (struct dlogutil_entry *) 33);
- assert(sv.data[1] == (struct dlogutil_entry *) 40);
- assert(sv.data[2] == (struct dlogutil_entry *) 41);
- assert(sv.data[3] == (struct dlogutil_entry *) 0);
- assert(sv.data[4] == (struct dlogutil_entry *) 20);
- assert(sv.data[5] == (struct dlogutil_entry *) 24);
- assert(sv.data[6] == (struct dlogutil_entry *) 25);
+ assert(sv.data[0] == (dlogutil_entry_s *) 33);
+ assert(sv.data[1] == (dlogutil_entry_s *) 40);
+ assert(sv.data[2] == (dlogutil_entry_s *) 41);
+ assert(sv.data[3] == (dlogutil_entry_s *) 0);
+ assert(sv.data[4] == (dlogutil_entry_s *) 20);
+ assert(sv.data[5] == (dlogutil_entry_s *) 24);
+ assert(sv.data[6] == (dlogutil_entry_s *) 25);
assert(sv.begin == 4);
assert(sv.end == 3);
- struct dlogutil_entry **const data = sv.data;
+ dlogutil_entry_s **const data = sv.data;
free_total = 0;
sort_vector_free(&sv);
assert(total_flushed == 0);
{
char buffer[1024];
int len;
- struct dlogutil_entry * sle = alloca(1024);
+ dlogutil_entry_s * sle = alloca(1024);
// No priority delimiter '>'.
len = snprintf(buffer, sizeof buffer, "<10 Jan 02 03:04:05 progname: msg");
#define STR1 "a"
-#define LE_SM(str, tsec, tnsec) {{sizeof(struct dlogutil_entry)+sizeof(str)+1, 0, 0, 1, 1, (tsec), (tnsec), 0U, 0U, 0U, 0U, 0U, 0U, 0U, LOGGER_ENTRY_MONOTONIC}, str}
-#define LE_SR(str, tsec, tnsec) {{sizeof(struct dlogutil_entry)+sizeof(str)+1, 0, 0, 1, 1, 0U, 0U, (tsec), (tnsec), 0U, 0U, 0U, 0U, 0U, LOGGER_ENTRY_REALTIME}, str}
-#define LE_RM(str, tsec, tnsec) {{sizeof(struct dlogutil_entry)+sizeof(str)+1, 0, 0, 1, 1, 0U, 0U, 0U, 0U, (tsec), (tnsec), 0U, 0U, 0U, LOGGER_ENTRY_MONOTONIC}, str}
-#define LE_RR(str, tsec, tnsec) {{sizeof(struct dlogutil_entry)+sizeof(str)+1, 0, 0, 1, 1, 0U, 0U, 0U, 0U, 0U, 0U, (tsec), (tnsec), 0U, LOGGER_ENTRY_REALTIME}, str}
+#define LE_SM(str, tsec, tnsec) {{sizeof(dlogutil_entry_s)+sizeof(str)+1, 0, 0, 1, 1, (tsec), (tnsec), 0U, 0U, 0U, 0U, 0U, 0U, 0U, LOGGER_ENTRY_MONOTONIC}, str}
+#define LE_SR(str, tsec, tnsec) {{sizeof(dlogutil_entry_s)+sizeof(str)+1, 0, 0, 1, 1, 0U, 0U, (tsec), (tnsec), 0U, 0U, 0U, 0U, 0U, LOGGER_ENTRY_REALTIME}, str}
+#define LE_RM(str, tsec, tnsec) {{sizeof(dlogutil_entry_s)+sizeof(str)+1, 0, 0, 1, 1, 0U, 0U, 0U, 0U, (tsec), (tnsec), 0U, 0U, 0U, LOGGER_ENTRY_MONOTONIC}, str}
+#define LE_RR(str, tsec, tnsec) {{sizeof(dlogutil_entry_s)+sizeof(str)+1, 0, 0, 1, 1, 0U, 0U, 0U, 0U, 0U, 0U, (tsec), (tnsec), 0U, LOGGER_ENTRY_REALTIME}, str}
static bool fail_malloc = false;
void *__real_malloc(size_t size);
return fail_malloc ? NULL : __real_malloc(size);
}
-void dont_call_this_callback(const struct dlogutil_entry *le, void *user_data)
+void dont_call_this_callback(const dlogutil_entry_s *le, void *user_data)
{
assert(false);
}
int callback_count = 0;
-void callback_check_msg(const struct dlogutil_entry *le, void *user_data)
+void callback_check_msg(const dlogutil_entry_s *le, void *user_data)
{
assert(le);
assert(user_data);
int check_sec = 0;
-void callback_check_sec(const struct dlogutil_entry *le, void *user_data)
+void callback_check_sec(const dlogutil_entry_s *le, void *user_data)
{
assert(le);
callback_count++;
}
-void callback_count_inc(const struct dlogutil_entry *le, void *user_data)
+void callback_count_inc(const dlogutil_entry_s *le, void *user_data)
{
assert(le);
assert(r);
const struct log_storage *s = log_storage_reader_get_storage(r);
- const struct dlogutil_entry *le = log_storage_reader_get_new_entry(r);
+ const dlogutil_entry_s *le = log_storage_reader_get_new_entry(r);
assert(le);
assert(s);
int32_t entry_sec;