liblog: replace "frontend" with "transport"
We still do not have any users of the 'frontend' interface, let's right a wrong and rename it to 'transport' as it makes more sense. Renames android_log_set_frontend, android_log_get_frontend and include/log/log_frontend.h. SideEffects: None Test: gTest liblog-unit-tests Bug: 27405083 Change-Id: I7c1c0f3dfdc7cf047285403e306edbd16ad1324d
This commit is contained in:
parent
04bbc8ea45
commit
81321a7980
13 changed files with 65 additions and 65 deletions
|
|
@ -108,10 +108,10 @@ SYNOPSIS
|
|||
|
||||
int android_log_destroy(android_log_context *ctx)
|
||||
|
||||
#include <log/log_frontend.h>
|
||||
#include <log/log_transport.h>
|
||||
|
||||
int android_set_log_frontend(int frontend_flag)
|
||||
int android_get_log_frontend()
|
||||
int android_set_log_transport(int transport_flag)
|
||||
int android_get_log_transport()
|
||||
|
||||
Link with -llog
|
||||
|
||||
|
|
@ -167,12 +167,12 @@ DESCRIPTION
|
|||
when opening the sub-log. It is recommended to open the log
|
||||
ANDROID_LOG_RDONLY in these cases.
|
||||
|
||||
android_set_log_frontend() selects frontend filters. Argument is either
|
||||
LOGGER_DEFAULT, LOGGER_LOGD, LOGGER_NULL or LOGGER_LOCAL. Log to logger
|
||||
daemon for default or logd, drop contents on floor, or log into local
|
||||
memory respectively. Both android_set_log_frontend() and
|
||||
android_get_log_frontend() return the current frontend mask, or a
|
||||
negative errno for any problems.
|
||||
android_set_log_transport() selects transport filters. Argument is
|
||||
either LOGGER_DEFAULT, LOGGER_LOGD, LOGGER_NULL or LOGGER_LOCAL. Log to
|
||||
logger daemon for default or logd, drop contents on floor, or log into
|
||||
local memory respectively. Both android_set_log_transport()
|
||||
and android_get_log_transport() return the current transport mask, or
|
||||
a negative errno for any problems.
|
||||
|
||||
ERRORS
|
||||
If messages fail, a negative error code will be returned to the caller.
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@
|
|||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include <log/log_frontend.h>
|
||||
#include <log/log_transport.h>
|
||||
|
||||
#include "config_read.h"
|
||||
#include "logger.h"
|
||||
|
|
@ -55,15 +55,15 @@ static void __android_log_add_transport(
|
|||
}
|
||||
|
||||
LIBLOG_HIDDEN void __android_log_config_read() {
|
||||
if (__android_log_frontend & LOGGER_LOCAL) {
|
||||
if (__android_log_transport & LOGGER_LOCAL) {
|
||||
extern struct android_log_transport_read localLoggerRead;
|
||||
|
||||
__android_log_add_transport(&__android_log_transport_read, &localLoggerRead);
|
||||
}
|
||||
|
||||
#if (FAKE_LOG_DEVICE == 0)
|
||||
if ((__android_log_frontend == LOGGER_DEFAULT) ||
|
||||
(__android_log_frontend & LOGGER_LOGD)) {
|
||||
if ((__android_log_transport == LOGGER_DEFAULT) ||
|
||||
(__android_log_transport & LOGGER_LOGD)) {
|
||||
extern struct android_log_transport_read logdLoggerRead;
|
||||
extern struct android_log_transport_read pmsgLoggerRead;
|
||||
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@
|
|||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include <log/log_frontend.h>
|
||||
#include <log/log_transport.h>
|
||||
|
||||
#include "config_write.h"
|
||||
#include "logger.h"
|
||||
|
|
@ -55,15 +55,15 @@ static void __android_log_add_transport(
|
|||
}
|
||||
|
||||
LIBLOG_HIDDEN void __android_log_config_write() {
|
||||
if (__android_log_frontend & LOGGER_LOCAL) {
|
||||
if (__android_log_transport & LOGGER_LOCAL) {
|
||||
extern struct android_log_transport_write localLoggerWrite;
|
||||
|
||||
__android_log_add_transport(&__android_log_transport_write,
|
||||
&localLoggerWrite);
|
||||
}
|
||||
|
||||
if ((__android_log_frontend == LOGGER_DEFAULT) ||
|
||||
(__android_log_frontend & LOGGER_LOGD)) {
|
||||
if ((__android_log_transport == LOGGER_DEFAULT) ||
|
||||
(__android_log_transport & LOGGER_LOGD)) {
|
||||
#if (FAKE_LOG_DEVICE == 0)
|
||||
extern struct android_log_transport_write logdLoggerWrite;
|
||||
extern struct android_log_transport_write pmsgLoggerWrite;
|
||||
|
|
@ -79,7 +79,7 @@ LIBLOG_HIDDEN void __android_log_config_write() {
|
|||
#endif
|
||||
}
|
||||
|
||||
if (__android_log_frontend & LOGGER_STDERR) {
|
||||
if (__android_log_transport & LOGGER_STDERR) {
|
||||
extern struct android_log_transport_write stderrLoggerWrite;
|
||||
|
||||
/*
|
||||
|
|
|
|||
|
|
@ -7,15 +7,15 @@
|
|||
** General Public License.
|
||||
*/
|
||||
|
||||
#ifndef _LIBS_LOG_FRONTEND_H
|
||||
#define _LIBS_LOG_FRONTEND_H
|
||||
#ifndef _LIBS_LOG_TRANSPORT_H
|
||||
#define _LIBS_LOG_TRANSPORT_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Logging frontends, bit mask to select features. Function returns selection.
|
||||
* Logging transports, bit mask to select features. Function returns selection.
|
||||
*/
|
||||
/* clang-format off */
|
||||
#define LOGGER_DEFAULT 0x00
|
||||
|
|
@ -26,12 +26,12 @@ extern "C" {
|
|||
#define LOGGER_STDERR 0x10 /* logs sent to stderr */
|
||||
/* clang-format on */
|
||||
|
||||
/* Both return the selected frontend flag mask, or negative errno */
|
||||
int android_set_log_frontend(int frontend_flag);
|
||||
int android_get_log_frontend();
|
||||
/* Both return the selected transport flag mask, or negative errno */
|
||||
int android_set_log_transport(int transport_flag);
|
||||
int android_get_log_transport();
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* _LIBS_LOG_FRONTEND_H */
|
||||
#endif /* _LIBS_LOG_TRANSPORT_H */
|
||||
|
|
@ -27,7 +27,7 @@
|
|||
#include <sys/types.h>
|
||||
|
||||
#include <cutils/list.h> /* template, no library dependency */
|
||||
#include <log/log_frontend.h>
|
||||
#include <log/log_transport.h>
|
||||
#include <private/android_filesystem_config.h>
|
||||
#include <private/android_logger.h>
|
||||
#include <system/thread_defs.h>
|
||||
|
|
@ -273,7 +273,7 @@ static int writeToLocalAvailable(log_id_t logId) {
|
|||
|
||||
/* Android hard coded permitted, system goes to logd */
|
||||
#if !defined(__MINGW32__)
|
||||
if (__android_log_frontend == LOGGER_DEFAULT) {
|
||||
if (__android_log_transport == LOGGER_DEFAULT) {
|
||||
uid = __android_log_uid();
|
||||
if ((uid < AID_APP) && (getpwuid(uid) != NULL)) {
|
||||
return -EPERM;
|
||||
|
|
|
|||
|
|
@ -193,7 +193,7 @@ LIBLOG_HIDDEN void __android_log_lock();
|
|||
LIBLOG_HIDDEN int __android_log_trylock();
|
||||
LIBLOG_HIDDEN void __android_log_unlock();
|
||||
|
||||
LIBLOG_HIDDEN int __android_log_frontend;
|
||||
LIBLOG_HIDDEN int __android_log_transport;
|
||||
|
||||
__END_DECLS
|
||||
|
||||
|
|
|
|||
|
|
@ -25,7 +25,7 @@
|
|||
#endif
|
||||
|
||||
#include <log/event_tag_map.h>
|
||||
#include <log/log_frontend.h>
|
||||
#include <log/log_transport.h>
|
||||
#include <private/android_filesystem_config.h>
|
||||
#include <private/android_logger.h>
|
||||
|
||||
|
|
@ -609,12 +609,12 @@ static int __write_to_log_null(log_id_t log_id, struct iovec* vec, size_t nr) {
|
|||
|
||||
/* Following functions need access to our internal write_to_log status */
|
||||
|
||||
LIBLOG_HIDDEN int __android_log_frontend;
|
||||
LIBLOG_HIDDEN int __android_log_transport;
|
||||
|
||||
LIBLOG_ABI_PUBLIC int android_set_log_frontend(int frontend_flag) {
|
||||
LIBLOG_ABI_PUBLIC int android_set_log_transport(int transport_flag) {
|
||||
int retval;
|
||||
|
||||
if (frontend_flag < 0) {
|
||||
if (transport_flag < 0) {
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
|
|
@ -622,7 +622,7 @@ LIBLOG_ABI_PUBLIC int android_set_log_frontend(int frontend_flag) {
|
|||
|
||||
__android_log_lock();
|
||||
|
||||
if (frontend_flag & LOGGER_NULL) {
|
||||
if (transport_flag & LOGGER_NULL) {
|
||||
write_to_log = __write_to_log_null;
|
||||
|
||||
__android_log_unlock();
|
||||
|
|
@ -630,12 +630,12 @@ LIBLOG_ABI_PUBLIC int android_set_log_frontend(int frontend_flag) {
|
|||
return retval;
|
||||
}
|
||||
|
||||
__android_log_frontend &= LOGGER_LOCAL | LOGGER_LOGD | LOGGER_STDERR;
|
||||
__android_log_transport &= LOGGER_LOCAL | LOGGER_LOGD | LOGGER_STDERR;
|
||||
|
||||
frontend_flag &= LOGGER_LOCAL | LOGGER_LOGD | LOGGER_STDERR;
|
||||
transport_flag &= LOGGER_LOCAL | LOGGER_LOGD | LOGGER_STDERR;
|
||||
|
||||
if (__android_log_frontend != frontend_flag) {
|
||||
__android_log_frontend = frontend_flag;
|
||||
if (__android_log_transport != transport_flag) {
|
||||
__android_log_transport = transport_flag;
|
||||
__android_log_config_write_close();
|
||||
__android_log_config_read_close();
|
||||
|
||||
|
|
@ -646,22 +646,22 @@ LIBLOG_ABI_PUBLIC int android_set_log_frontend(int frontend_flag) {
|
|||
write_to_log = __write_to_log_init;
|
||||
}
|
||||
|
||||
retval = __android_log_frontend;
|
||||
retval = __android_log_transport;
|
||||
|
||||
__android_log_unlock();
|
||||
|
||||
return retval;
|
||||
}
|
||||
|
||||
LIBLOG_ABI_PUBLIC int android_get_log_frontend() {
|
||||
LIBLOG_ABI_PUBLIC int android_get_log_transport() {
|
||||
int ret = LOGGER_DEFAULT;
|
||||
|
||||
__android_log_lock();
|
||||
if (write_to_log == __write_to_log_null) {
|
||||
ret = LOGGER_NULL;
|
||||
} else {
|
||||
__android_log_frontend &= LOGGER_LOCAL | LOGGER_LOGD | LOGGER_STDERR;
|
||||
ret = __android_log_frontend;
|
||||
__android_log_transport &= LOGGER_LOCAL | LOGGER_LOGD | LOGGER_STDERR;
|
||||
ret = __android_log_transport;
|
||||
if ((write_to_log != __write_to_log_init) &&
|
||||
(write_to_log != __write_to_log_daemon)) {
|
||||
ret = -EINVAL;
|
||||
|
|
|
|||
|
|
@ -27,7 +27,7 @@
|
|||
#include <android-base/file.h>
|
||||
#include <cutils/sockets.h>
|
||||
#include <log/event_tag_map.h>
|
||||
#include <log/log_frontend.h>
|
||||
#include <log/log_transport.h>
|
||||
#include <private/android_logger.h>
|
||||
|
||||
#include "benchmark.h"
|
||||
|
|
@ -80,11 +80,11 @@ static void BM_log_maximum(int iters) {
|
|||
BENCHMARK(BM_log_maximum);
|
||||
|
||||
static void set_log_null() {
|
||||
android_set_log_frontend(LOGGER_NULL);
|
||||
android_set_log_transport(LOGGER_NULL);
|
||||
}
|
||||
|
||||
static void set_log_default() {
|
||||
android_set_log_frontend(LOGGER_DEFAULT);
|
||||
android_set_log_transport(LOGGER_DEFAULT);
|
||||
}
|
||||
|
||||
static void BM_log_maximum_null(int iters) {
|
||||
|
|
|
|||
|
|
@ -36,7 +36,7 @@
|
|||
#endif
|
||||
#include <gtest/gtest.h>
|
||||
#include <log/log_event_list.h>
|
||||
#include <log/log_frontend.h>
|
||||
#include <log/log_transport.h>
|
||||
#include <log/logprint.h>
|
||||
#include <private/android_filesystem_config.h>
|
||||
#include <private/android_logger.h>
|
||||
|
|
@ -255,7 +255,7 @@ TEST(liblog, __android_log_btwrite__android_logger_list_read) {
|
|||
}
|
||||
|
||||
#if (defined(__ANDROID__) || defined(USING_LOGGER_LOCAL))
|
||||
static void print_frontend(const char* prefix, int logger) {
|
||||
static void print_transport(const char* prefix, int logger) {
|
||||
static const char orstr[] = " | ";
|
||||
|
||||
if (!prefix) {
|
||||
|
|
@ -305,21 +305,21 @@ static void print_frontend(const char* prefix, int logger) {
|
|||
// This test makes little sense standalone, and requires the tests ahead
|
||||
// and behind us, to make us whole. We could incorporate a prefix and
|
||||
// suffix test to make this standalone, but opted to not complicate this.
|
||||
TEST(liblog, android_set_log_frontend) {
|
||||
TEST(liblog, android_set_log_transport) {
|
||||
#if (defined(__ANDROID__) || defined(USING_LOGGER_LOCAL))
|
||||
#ifdef TEST_PREFIX
|
||||
TEST_PREFIX
|
||||
#endif
|
||||
|
||||
int logger = android_get_log_frontend();
|
||||
print_frontend("android_get_log_frontend = ", logger);
|
||||
int logger = android_get_log_transport();
|
||||
print_transport("android_get_log_transport = ", logger);
|
||||
EXPECT_NE(LOGGER_NULL, logger);
|
||||
|
||||
int ret;
|
||||
EXPECT_EQ(LOGGER_NULL, ret = android_set_log_frontend(LOGGER_NULL));
|
||||
print_frontend("android_set_log_frontend = ", ret);
|
||||
EXPECT_EQ(LOGGER_NULL, ret = android_get_log_frontend());
|
||||
print_frontend("android_get_log_frontend = ", ret);
|
||||
EXPECT_EQ(LOGGER_NULL, ret = android_set_log_transport(LOGGER_NULL));
|
||||
print_transport("android_set_log_transport = ", ret);
|
||||
EXPECT_EQ(LOGGER_NULL, ret = android_get_log_transport());
|
||||
print_transport("android_get_log_transport = ", ret);
|
||||
|
||||
pid_t pid = getpid();
|
||||
|
||||
|
|
@ -364,10 +364,10 @@ TEST(liblog, android_set_log_frontend) {
|
|||
|
||||
android_logger_list_close(logger_list);
|
||||
|
||||
EXPECT_EQ(logger, ret = android_set_log_frontend(logger));
|
||||
print_frontend("android_set_log_frontend = ", ret);
|
||||
EXPECT_EQ(logger, ret = android_get_log_frontend());
|
||||
print_frontend("android_get_log_frontend = ", ret);
|
||||
EXPECT_EQ(logger, ret = android_set_log_transport(logger));
|
||||
print_transport("android_set_log_transport = ", ret);
|
||||
EXPECT_EQ(logger, ret = android_get_log_transport());
|
||||
print_transport("android_get_log_transport = ", ret);
|
||||
|
||||
// False negative if liblog.__android_log_btwrite__android_logger_list_read
|
||||
// fails above, so we will likely succeed. But we will have so many
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
#ifdef __ANDROID__
|
||||
#include <log/log_frontend.h>
|
||||
#define TEST_PREFIX android_set_log_frontend(LOGGER_DEFAULT);
|
||||
#include <log/log_transport.h>
|
||||
#define TEST_PREFIX android_set_log_transport(LOGGER_DEFAULT);
|
||||
#endif
|
||||
#include "liblog_test.cpp"
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
#include <log/log_frontend.h>
|
||||
#include <log/log_transport.h>
|
||||
#define liblog liblog_local
|
||||
#define TEST_PREFIX android_set_log_frontend(LOGGER_LOCAL);
|
||||
#define TEST_PREFIX android_set_log_transport(LOGGER_LOCAL);
|
||||
#include "liblog_test.cpp"
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
#include <log/log_frontend.h>
|
||||
#include <log/log_transport.h>
|
||||
#define liblog liblog_stderr
|
||||
#define TEST_PREFIX android_set_log_frontend(LOGGER_STDERR);
|
||||
#define TEST_PREFIX android_set_log_transport(LOGGER_STDERR);
|
||||
#define USING_LOGGER_STDERR
|
||||
#include "liblog_test.cpp"
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
#include <log/log_frontend.h>
|
||||
#include <log/log_transport.h>
|
||||
#define liblog liblog_stderr_local
|
||||
#define TEST_PREFIX android_set_log_frontend(LOGGER_LOCAL | LOGGER_STDERR);
|
||||
#define TEST_PREFIX android_set_log_transport(LOGGER_LOCAL | LOGGER_STDERR);
|
||||
#include "liblog_test.cpp"
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue