liblog: add android_log_timestamp() private function

(cherry pick from commit 500afc7532)

Change-Id: Iefbea3b1be2f97cfdeb35e5330e5495e0337215b
This commit is contained in:
Mark Salyzyn 2015-09-08 08:32:01 -07:00 committed by Rom Lemarchand
parent 9cb92047e5
commit aa5abfd84e
2 changed files with 27 additions and 0 deletions

View file

@ -183,6 +183,8 @@ struct logger_list *android_logger_list_open(log_id_t id,
pid_t pid);
#define android_logger_list_close android_logger_list_free
char android_log_timestamp();
/*
* log_id_t helpers
*/

View file

@ -176,3 +176,28 @@ int __android_log_is_loggable(int prio, const char *tag, int def)
int logLevel = __android_log_level(tag, def);
return logLevel >= 0 && prio >= logLevel;
}
char android_log_timestamp()
{
static struct cache r_time_cache = { NULL, -1, 0 };
static struct cache p_time_cache = { NULL, -1, 0 };
static uint32_t serial;
uint32_t current_serial;
char retval;
pthread_mutex_lock(&lock);
current_serial = __system_property_area_serial();
if (current_serial != serial) {
refresh_cache(&r_time_cache, "ro.logd.timestamp");
refresh_cache(&p_time_cache, "persist.logd.timestamp");
serial = current_serial;
}
if (!(retval = p_time_cache.c)) {
retval = r_time_cache.c;
}
pthread_mutex_unlock(&lock);
return tolower(retval ?: 'r');
}