#include "logconfig.h"
void __configure_deduplicate(struct log_config *config);
-bool deduplicate(const char *msg, size_t len, struct timespec *tp);
void __deduplicate_destroy();
+extern bool (*deduplicate_func)(const char *, size_t, struct timespec *);
#endif /* _DEDUPLICATE_H_ */
}
}
-bool deduplicate(const char *msg, size_t len, struct timespec *tp)
-{
- return deduplicate_func && deduplicate_func(msg, len, tp);
-}
-
void __deduplicate_destroy()
{
known_hashes_size = 0;
len = sizeof buf - 1;
struct timespec tp;
- int result = clock_gettime(CLOCK_MONOTONIC, &tp);
- if (result < 0)
- return DLOG_ERROR_NONE;
+ if (deduplicate_func && !clock_gettime(CLOCK_MONOTONIC, &tp)) {
+ if (deduplicate_func(buf, len, &tp))
+ return DLOG_ERROR_NONE;
+ return write_to_log(log_id, prio, tag, buf, &tp);
+ }
- if (deduplicate(buf, len, &tp))
- return 0;
- return write_to_log(log_id, prio, tag, buf, &tp);
+ return write_to_log(log_id, prio, tag, buf, NULL);
}
static int __write_to_log(log_id_t log_id, int prio, const char *tag, const char *fmt, va_list ap, bool check_should_log, bool secure_log)
#ifdef USE_ANDROID_MONOTONIC
struct iovec vec[4];
struct android_logger_footer alf;
+ struct timespec ts;
+
+ if (!tp_mono) {
+ int result = clock_gettime(CLOCK_MONOTONIC, &ts);
+ if (result >= 0)
+ tp_mono = &ts;
+ }
alf.magic = ANDROID_LOGGER_FOOTER_MAGIC;
- alf.sec_sent_mono = tp_mono->tv_sec;
- alf.nsec_sent_mono = tp_mono->tv_nsec;
+ if (tp_mono) {
+ alf.sec_sent_mono = tp_mono->tv_sec;
+ alf.nsec_sent_mono = tp_mono->tv_nsec;
+ } else {
+ alf.sec_sent_mono = 0;
+ alf.nsec_sent_mono = -1;
+ }
vec[3].iov_base = (void *) &alf;
vec[3].iov_len = sizeof alf;