Merge "Revert "logd: liblog: logcat: switch to android_log_clockid()"" am: b566435b02
am: a64dd2d0b4
* commit 'a64dd2d0b40c7662e779acaf20a5ad374e706e21':
Revert "logd: liblog: logcat: switch to android_log_clockid()"
This commit is contained in:
commit
b97aaca6b2
7 changed files with 27 additions and 23 deletions
|
|
@ -11,8 +11,6 @@
|
||||||
#define _LIBS_LOG_LOGGER_H
|
#define _LIBS_LOG_LOGGER_H
|
||||||
|
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include <time.h>
|
|
||||||
|
|
||||||
#include <log/log.h>
|
#include <log/log.h>
|
||||||
#include <log/log_read.h>
|
#include <log/log_read.h>
|
||||||
|
|
||||||
|
|
@ -185,7 +183,7 @@ struct logger_list *android_logger_list_open(log_id_t id,
|
||||||
pid_t pid);
|
pid_t pid);
|
||||||
#define android_logger_list_close android_logger_list_free
|
#define android_logger_list_close android_logger_list_free
|
||||||
|
|
||||||
clockid_t android_log_clockid();
|
char android_log_timestamp();
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* log_id_t helpers
|
* log_id_t helpers
|
||||||
|
|
|
||||||
|
|
@ -196,18 +196,18 @@ int __android_log_is_loggable(int prio, const char *tag, int default_prio)
|
||||||
* rare, we can accept a trylock failure gracefully. Use a separate
|
* rare, we can accept a trylock failure gracefully. Use a separate
|
||||||
* lock from is_loggable to keep contention down b/25563384.
|
* lock from is_loggable to keep contention down b/25563384.
|
||||||
*/
|
*/
|
||||||
static pthread_mutex_t lock_clockid = PTHREAD_MUTEX_INITIALIZER;
|
static pthread_mutex_t lock_timestamp = PTHREAD_MUTEX_INITIALIZER;
|
||||||
|
|
||||||
clockid_t android_log_clockid()
|
char android_log_timestamp()
|
||||||
{
|
{
|
||||||
static struct cache r_time_cache = { NULL, -1, 0 };
|
static struct cache r_time_cache = { NULL, -1, 0 };
|
||||||
static struct cache p_time_cache = { NULL, -1, 0 };
|
static struct cache p_time_cache = { NULL, -1, 0 };
|
||||||
char c;
|
char retval;
|
||||||
|
|
||||||
if (pthread_mutex_trylock(&lock_clockid)) {
|
if (pthread_mutex_trylock(&lock_timestamp)) {
|
||||||
/* We are willing to accept some race in this context */
|
/* We are willing to accept some race in this context */
|
||||||
if (!(c = p_time_cache.c)) {
|
if (!(retval = p_time_cache.c)) {
|
||||||
c = r_time_cache.c;
|
retval = r_time_cache.c;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
static uint32_t serial;
|
static uint32_t serial;
|
||||||
|
|
@ -217,12 +217,12 @@ clockid_t android_log_clockid()
|
||||||
refresh_cache(&p_time_cache, "persist.logd.timestamp");
|
refresh_cache(&p_time_cache, "persist.logd.timestamp");
|
||||||
serial = current_serial;
|
serial = current_serial;
|
||||||
}
|
}
|
||||||
if (!(c = p_time_cache.c)) {
|
if (!(retval = p_time_cache.c)) {
|
||||||
c = r_time_cache.c;
|
retval = r_time_cache.c;
|
||||||
}
|
}
|
||||||
|
|
||||||
pthread_mutex_unlock(&lock_clockid);
|
pthread_mutex_unlock(&lock_timestamp);
|
||||||
}
|
}
|
||||||
|
|
||||||
return (tolower(c) == 'm') ? CLOCK_MONOTONIC : CLOCK_REALTIME;
|
return tolower(retval ?: 'r');
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -212,7 +212,11 @@ static int __write_to_log_daemon(log_id_t log_id, struct iovec *vec, size_t nr)
|
||||||
* };
|
* };
|
||||||
*/
|
*/
|
||||||
|
|
||||||
clock_gettime(android_log_clockid(), &ts);
|
if (android_log_timestamp() == 'm') {
|
||||||
|
clock_gettime(CLOCK_MONOTONIC, &ts);
|
||||||
|
} else {
|
||||||
|
clock_gettime(CLOCK_REALTIME, &ts);
|
||||||
|
}
|
||||||
|
|
||||||
pmsg_header.magic = LOGGER_MAGIC;
|
pmsg_header.magic = LOGGER_MAGIC;
|
||||||
pmsg_header.len = sizeof(pmsg_header) + sizeof(header);
|
pmsg_header.len = sizeof(pmsg_header) + sizeof(header);
|
||||||
|
|
|
||||||
|
|
@ -203,7 +203,7 @@ AndroidLogFormat *android_log_format_new()
|
||||||
p_ret->year_output = false;
|
p_ret->year_output = false;
|
||||||
p_ret->zone_output = false;
|
p_ret->zone_output = false;
|
||||||
p_ret->epoch_output = false;
|
p_ret->epoch_output = false;
|
||||||
p_ret->monotonic_output = android_log_clockid() == CLOCK_MONOTONIC;
|
p_ret->monotonic_output = android_log_timestamp() == 'm';
|
||||||
|
|
||||||
return p_ret;
|
return p_ret;
|
||||||
}
|
}
|
||||||
|
|
@ -1262,7 +1262,7 @@ char *android_log_formatLogLine (
|
||||||
nsec = entry->tv_nsec;
|
nsec = entry->tv_nsec;
|
||||||
if (p_format->monotonic_output) {
|
if (p_format->monotonic_output) {
|
||||||
// prevent convertMonotonic from being called if logd is monotonic
|
// prevent convertMonotonic from being called if logd is monotonic
|
||||||
if (android_log_clockid() != CLOCK_MONOTONIC) {
|
if (android_log_timestamp() != 'm') {
|
||||||
struct timespec time;
|
struct timespec time;
|
||||||
convertMonotonic(&time, entry);
|
convertMonotonic(&time, entry);
|
||||||
now = time.tv_sec;
|
now = time.tv_sec;
|
||||||
|
|
|
||||||
|
|
@ -398,9 +398,11 @@ static log_time lastLogTime(char *outputFileName) {
|
||||||
return retval;
|
return retval;
|
||||||
}
|
}
|
||||||
|
|
||||||
clockid_t clock_type = android_log_clockid();
|
log_time now(CLOCK_REALTIME);
|
||||||
log_time now(clock_type);
|
bool monotonic = android_log_timestamp() == 'm';
|
||||||
bool monotonic = clock_type == CLOCK_MONOTONIC;
|
if (monotonic) {
|
||||||
|
now = log_time(CLOCK_MONOTONIC);
|
||||||
|
}
|
||||||
|
|
||||||
std::string directory;
|
std::string directory;
|
||||||
char *file = strrchr(outputFileName, '/');
|
char *file = strrchr(outputFileName, '/');
|
||||||
|
|
|
||||||
|
|
@ -76,7 +76,7 @@ TEST(logcat, buckets) {
|
||||||
|
|
||||||
TEST(logcat, year) {
|
TEST(logcat, year) {
|
||||||
|
|
||||||
if (android_log_clockid() == CLOCK_MONOTONIC) {
|
if (android_log_timestamp() == 'm') {
|
||||||
fprintf(stderr, "Skipping test, logd is monotonic time\n");
|
fprintf(stderr, "Skipping test, logd is monotonic time\n");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
@ -147,7 +147,7 @@ char *fgetLongTime(char *buffer, size_t buflen, FILE *fp) {
|
||||||
|
|
||||||
TEST(logcat, tz) {
|
TEST(logcat, tz) {
|
||||||
|
|
||||||
if (android_log_clockid() == CLOCK_MONOTONIC) {
|
if (android_log_timestamp() == 'm') {
|
||||||
fprintf(stderr, "Skipping test, logd is monotonic time\n");
|
fprintf(stderr, "Skipping test, logd is monotonic time\n");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -128,7 +128,7 @@ void LogBuffer::init() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
bool lastMonotonic = monotonic;
|
bool lastMonotonic = monotonic;
|
||||||
monotonic = android_log_clockid() == CLOCK_MONOTONIC;
|
monotonic = android_log_timestamp() == 'm';
|
||||||
if (lastMonotonic == monotonic) {
|
if (lastMonotonic == monotonic) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
@ -167,7 +167,7 @@ void LogBuffer::init() {
|
||||||
}
|
}
|
||||||
|
|
||||||
LogBuffer::LogBuffer(LastLogTimes *times):
|
LogBuffer::LogBuffer(LastLogTimes *times):
|
||||||
monotonic(android_log_clockid() == CLOCK_MONOTONIC),
|
monotonic(android_log_timestamp() == 'm'),
|
||||||
mTimes(*times) {
|
mTimes(*times) {
|
||||||
pthread_mutex_init(&mLogElementsLock, NULL);
|
pthread_mutex_init(&mLogElementsLock, NULL);
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue