Merge "rotate_logs: Clean up the header includes." am: 30ec005104 am: c8eba4a036

am: 41763a5dbb

Change-Id: I257ece1d0df06c45faac1501c8cc3c13da43a3db
This commit is contained in:
Tao Bao
2017-10-18 20:38:58 +00:00
committed by android-build-merger
2 changed files with 65 additions and 79 deletions
+10 -18
View File
@@ -31,29 +31,21 @@
static const std::string LAST_KMSG_FILTER = "recovery/last_kmsg"; static const std::string LAST_KMSG_FILTER = "recovery/last_kmsg";
static const std::string LAST_LOG_FILTER = "recovery/last_log"; static const std::string LAST_LOG_FILTER = "recovery/last_log";
ssize_t logbasename( ssize_t logbasename(log_id_t /* id */, char /* prio */, const char* filename, const char* /* buf */,
log_id_t /* logId */, size_t len, void* arg) {
char /* prio */, bool* do_rotate = static_cast<bool*>(arg);
const char *filename,
const char * /* buf */, size_t len,
void *arg) {
bool* doRotate = static_cast<bool*>(arg);
if (LAST_KMSG_FILTER.find(filename) != std::string::npos || if (LAST_KMSG_FILTER.find(filename) != std::string::npos ||
LAST_LOG_FILTER.find(filename) != std::string::npos) { LAST_LOG_FILTER.find(filename) != std::string::npos) {
*doRotate = true; *do_rotate = true;
} }
return len; return len;
} }
ssize_t logrotate( ssize_t logrotate(log_id_t id, char prio, const char* filename, const char* buf, size_t len,
log_id_t logId,
char prio,
const char *filename,
const char *buf, size_t len,
void* arg) { void* arg) {
bool* doRotate = static_cast<bool*>(arg); bool* do_rotate = static_cast<bool*>(arg);
if (!*doRotate) { if (!*do_rotate) {
return __android_log_pmsg_file_write(logId, prio, filename, buf, len); return __android_log_pmsg_file_write(id, prio, filename, buf, len);
} }
std::string name(filename); std::string name(filename);
@@ -62,7 +54,7 @@ ssize_t logrotate(
if (LAST_KMSG_FILTER.find(sub) == std::string::npos && if (LAST_KMSG_FILTER.find(sub) == std::string::npos &&
LAST_LOG_FILTER.find(sub) == std::string::npos) { LAST_LOG_FILTER.find(sub) == std::string::npos) {
return __android_log_pmsg_file_write(logId, prio, filename, buf, len); return __android_log_pmsg_file_write(id, prio, filename, buf, len);
} }
// filename rotation // filename rotation
@@ -82,7 +74,7 @@ ssize_t logrotate(
} }
} }
return __android_log_pmsg_file_write(logId, prio, name.c_str(), buf, len); return __android_log_pmsg_file_write(id, prio, name.c_str(), buf, len);
} }
// Rename last_log -> last_log.1 -> last_log.2 -> ... -> last_log.$max. // Rename last_log -> last_log.1 -> last_log.2 -> ... -> last_log.$max.
+6 -12
View File
@@ -17,23 +17,17 @@
#ifndef _ROTATE_LOGS_H #ifndef _ROTATE_LOGS_H
#define _ROTATE_LOGS_H #define _ROTATE_LOGS_H
#include <string> #include <stddef.h>
#include <sys/types.h>
#include <private/android_logger.h> /* private pmsg functions */ #include <log/log_id.h>
constexpr int KEEP_LOG_COUNT = 10; static constexpr int KEEP_LOG_COUNT = 10;
ssize_t logbasename(log_id_t /* logId */, ssize_t logbasename(log_id_t id, char prio, const char* filename, const char* buf, size_t len,
char /* prio */,
const char *filename,
const char * /* buf */, size_t len,
void* arg); void* arg);
ssize_t logrotate( ssize_t logrotate(log_id_t id, char prio, const char* filename, const char* buf, size_t len,
log_id_t logId,
char prio,
const char *filename,
const char *buf, size_t len,
void* arg); void* arg);
// Rename last_log -> last_log.1 -> last_log.2 -> ... -> last_log.$max. // Rename last_log -> last_log.1 -> last_log.2 -> ... -> last_log.$max.