summaryrefslogtreecommitdiffstats
path: root/include/log
diff options
context:
space:
mode:
Diffstat (limited to 'include/log')
-rw-r--r--include/log/log.h120
-rw-r--r--include/log/log_read.h12
-rw-r--r--include/log/logd.h15
-rw-r--r--include/log/logger.h7
-rw-r--r--include/log/logprint.h1
-rw-r--r--include/log/uio.h13
6 files changed, 119 insertions, 49 deletions
diff --git a/include/log/log.h b/include/log/log.h
index ace12d6..ce253e2 100644
--- a/include/log/log.h
+++ b/include/log/log.h
@@ -28,14 +28,12 @@
#ifndef _LIBS_LOG_LOG_H
#define _LIBS_LOG_LOG_H
-#include <sys/types.h>
-#ifdef HAVE_PTHREADS
-#include <pthread.h>
-#endif
#include <stdarg.h>
#include <stdio.h>
+#include <sys/types.h>
#include <time.h>
#include <unistd.h>
+
#include <log/logd.h>
#include <log/uio.h>
@@ -69,6 +67,23 @@ extern "C" {
// ---------------------------------------------------------------------
+#ifndef __predict_false
+#define __predict_false(exp) __builtin_expect((exp) != 0, 0)
+#endif
+
+/*
+ * -DLINT_RLOG in sources that you want to enforce that all logging
+ * goes to the radio log buffer. If any logging goes to any of the other
+ * log buffers, there will be a compile or link error to highlight the
+ * problem. This is not a replacement for a full audit of the code since
+ * this only catches compiled code, not ifdef'd debug code. Options to
+ * defining this, either temporarily to do a spot check, or permanently
+ * to enforce, in all the communications trees; We have hopes to ensure
+ * that by supplying just the radio log buffer that the communications
+ * teams will have their one-stop shop for triaging issues.
+ */
+#ifndef LINT_RLOG
+
/*
* Simplified macro to send a verbose log message using the current LOG_TAG.
*/
@@ -81,14 +96,12 @@ extern "C" {
#endif
#endif
-#define CONDITION(cond) (__builtin_expect((cond)!=0, 0))
-
#ifndef ALOGV_IF
#if LOG_NDEBUG
#define ALOGV_IF(cond, ...) ((void)0)
#else
#define ALOGV_IF(cond, ...) \
- ( (CONDITION(cond)) \
+ ( (__predict_false(cond)) \
? ((void)ALOG(LOG_VERBOSE, LOG_TAG, __VA_ARGS__)) \
: (void)0 )
#endif
@@ -103,7 +116,7 @@ extern "C" {
#ifndef ALOGD_IF
#define ALOGD_IF(cond, ...) \
- ( (CONDITION(cond)) \
+ ( (__predict_false(cond)) \
? ((void)ALOG(LOG_DEBUG, LOG_TAG, __VA_ARGS__)) \
: (void)0 )
#endif
@@ -117,7 +130,7 @@ extern "C" {
#ifndef ALOGI_IF
#define ALOGI_IF(cond, ...) \
- ( (CONDITION(cond)) \
+ ( (__predict_false(cond)) \
? ((void)ALOG(LOG_INFO, LOG_TAG, __VA_ARGS__)) \
: (void)0 )
#endif
@@ -131,7 +144,7 @@ extern "C" {
#ifndef ALOGW_IF
#define ALOGW_IF(cond, ...) \
- ( (CONDITION(cond)) \
+ ( (__predict_false(cond)) \
? ((void)ALOG(LOG_WARN, LOG_TAG, __VA_ARGS__)) \
: (void)0 )
#endif
@@ -145,7 +158,7 @@ extern "C" {
#ifndef ALOGE_IF
#define ALOGE_IF(cond, ...) \
- ( (CONDITION(cond)) \
+ ( (__predict_false(cond)) \
? ((void)ALOG(LOG_ERROR, LOG_TAG, __VA_ARGS__)) \
: (void)0 )
#endif
@@ -203,7 +216,8 @@ extern "C" {
* Simplified macro to send a verbose system log message using the current LOG_TAG.
*/
#ifndef SLOGV
-#define __SLOGV(...) ((void)__android_log_buf_print(LOG_ID_SYSTEM, ANDROID_LOG_VERBOSE, LOG_TAG, __VA_ARGS__))
+#define __SLOGV(...) \
+ ((void)__android_log_buf_print(LOG_ID_SYSTEM, ANDROID_LOG_VERBOSE, LOG_TAG, __VA_ARGS__))
#if LOG_NDEBUG
#define SLOGV(...) do { if (0) { __SLOGV(__VA_ARGS__); } } while (0)
#else
@@ -211,14 +225,12 @@ extern "C" {
#endif
#endif
-#define CONDITION(cond) (__builtin_expect((cond)!=0, 0))
-
#ifndef SLOGV_IF
#if LOG_NDEBUG
#define SLOGV_IF(cond, ...) ((void)0)
#else
#define SLOGV_IF(cond, ...) \
- ( (CONDITION(cond)) \
+ ( (__predict_false(cond)) \
? ((void)__android_log_buf_print(LOG_ID_SYSTEM, ANDROID_LOG_VERBOSE, LOG_TAG, __VA_ARGS__)) \
: (void)0 )
#endif
@@ -228,12 +240,13 @@ extern "C" {
* Simplified macro to send a debug system log message using the current LOG_TAG.
*/
#ifndef SLOGD
-#define SLOGD(...) ((void)__android_log_buf_print(LOG_ID_SYSTEM, ANDROID_LOG_DEBUG, LOG_TAG, __VA_ARGS__))
+#define SLOGD(...) \
+ ((void)__android_log_buf_print(LOG_ID_SYSTEM, ANDROID_LOG_DEBUG, LOG_TAG, __VA_ARGS__))
#endif
#ifndef SLOGD_IF
#define SLOGD_IF(cond, ...) \
- ( (CONDITION(cond)) \
+ ( (__predict_false(cond)) \
? ((void)__android_log_buf_print(LOG_ID_SYSTEM, ANDROID_LOG_DEBUG, LOG_TAG, __VA_ARGS__)) \
: (void)0 )
#endif
@@ -242,12 +255,13 @@ extern "C" {
* Simplified macro to send an info system log message using the current LOG_TAG.
*/
#ifndef SLOGI
-#define SLOGI(...) ((void)__android_log_buf_print(LOG_ID_SYSTEM, ANDROID_LOG_INFO, LOG_TAG, __VA_ARGS__))
+#define SLOGI(...) \
+ ((void)__android_log_buf_print(LOG_ID_SYSTEM, ANDROID_LOG_INFO, LOG_TAG, __VA_ARGS__))
#endif
#ifndef SLOGI_IF
#define SLOGI_IF(cond, ...) \
- ( (CONDITION(cond)) \
+ ( (__predict_false(cond)) \
? ((void)__android_log_buf_print(LOG_ID_SYSTEM, ANDROID_LOG_INFO, LOG_TAG, __VA_ARGS__)) \
: (void)0 )
#endif
@@ -256,12 +270,13 @@ extern "C" {
* Simplified macro to send a warning system log message using the current LOG_TAG.
*/
#ifndef SLOGW
-#define SLOGW(...) ((void)__android_log_buf_print(LOG_ID_SYSTEM, ANDROID_LOG_WARN, LOG_TAG, __VA_ARGS__))
+#define SLOGW(...) \
+ ((void)__android_log_buf_print(LOG_ID_SYSTEM, ANDROID_LOG_WARN, LOG_TAG, __VA_ARGS__))
#endif
#ifndef SLOGW_IF
#define SLOGW_IF(cond, ...) \
- ( (CONDITION(cond)) \
+ ( (__predict_false(cond)) \
? ((void)__android_log_buf_print(LOG_ID_SYSTEM, ANDROID_LOG_WARN, LOG_TAG, __VA_ARGS__)) \
: (void)0 )
#endif
@@ -270,23 +285,27 @@ extern "C" {
* Simplified macro to send an error system log message using the current LOG_TAG.
*/
#ifndef SLOGE
-#define SLOGE(...) ((void)__android_log_buf_print(LOG_ID_SYSTEM, ANDROID_LOG_ERROR, LOG_TAG, __VA_ARGS__))
+#define SLOGE(...) \
+ ((void)__android_log_buf_print(LOG_ID_SYSTEM, ANDROID_LOG_ERROR, LOG_TAG, __VA_ARGS__))
#endif
#ifndef SLOGE_IF
#define SLOGE_IF(cond, ...) \
- ( (CONDITION(cond)) \
+ ( (__predict_false(cond)) \
? ((void)__android_log_buf_print(LOG_ID_SYSTEM, ANDROID_LOG_ERROR, LOG_TAG, __VA_ARGS__)) \
: (void)0 )
#endif
+#endif /* !LINT_RLOG */
+
// ---------------------------------------------------------------------
/*
* Simplified macro to send a verbose radio log message using the current LOG_TAG.
*/
#ifndef RLOGV
-#define __RLOGV(...) ((void)__android_log_buf_print(LOG_ID_RADIO, ANDROID_LOG_VERBOSE, LOG_TAG, __VA_ARGS__))
+#define __RLOGV(...) \
+ ((void)__android_log_buf_print(LOG_ID_RADIO, ANDROID_LOG_VERBOSE, LOG_TAG, __VA_ARGS__))
#if LOG_NDEBUG
#define RLOGV(...) do { if (0) { __RLOGV(__VA_ARGS__); } } while (0)
#else
@@ -294,14 +313,12 @@ extern "C" {
#endif
#endif
-#define CONDITION(cond) (__builtin_expect((cond)!=0, 0))
-
#ifndef RLOGV_IF
#if LOG_NDEBUG
#define RLOGV_IF(cond, ...) ((void)0)
#else
#define RLOGV_IF(cond, ...) \
- ( (CONDITION(cond)) \
+ ( (__predict_false(cond)) \
? ((void)__android_log_buf_print(LOG_ID_RADIO, ANDROID_LOG_VERBOSE, LOG_TAG, __VA_ARGS__)) \
: (void)0 )
#endif
@@ -311,12 +328,13 @@ extern "C" {
* Simplified macro to send a debug radio log message using the current LOG_TAG.
*/
#ifndef RLOGD
-#define RLOGD(...) ((void)__android_log_buf_print(LOG_ID_RADIO, ANDROID_LOG_DEBUG, LOG_TAG, __VA_ARGS__))
+#define RLOGD(...) \
+ ((void)__android_log_buf_print(LOG_ID_RADIO, ANDROID_LOG_DEBUG, LOG_TAG, __VA_ARGS__))
#endif
#ifndef RLOGD_IF
#define RLOGD_IF(cond, ...) \
- ( (CONDITION(cond)) \
+ ( (__predict_false(cond)) \
? ((void)__android_log_buf_print(LOG_ID_RADIO, ANDROID_LOG_DEBUG, LOG_TAG, __VA_ARGS__)) \
: (void)0 )
#endif
@@ -325,12 +343,13 @@ extern "C" {
* Simplified macro to send an info radio log message using the current LOG_TAG.
*/
#ifndef RLOGI
-#define RLOGI(...) ((void)__android_log_buf_print(LOG_ID_RADIO, ANDROID_LOG_INFO, LOG_TAG, __VA_ARGS__))
+#define RLOGI(...) \
+ ((void)__android_log_buf_print(LOG_ID_RADIO, ANDROID_LOG_INFO, LOG_TAG, __VA_ARGS__))
#endif
#ifndef RLOGI_IF
#define RLOGI_IF(cond, ...) \
- ( (CONDITION(cond)) \
+ ( (__predict_false(cond)) \
? ((void)__android_log_buf_print(LOG_ID_RADIO, ANDROID_LOG_INFO, LOG_TAG, __VA_ARGS__)) \
: (void)0 )
#endif
@@ -339,12 +358,13 @@ extern "C" {
* Simplified macro to send a warning radio log message using the current LOG_TAG.
*/
#ifndef RLOGW
-#define RLOGW(...) ((void)__android_log_buf_print(LOG_ID_RADIO, ANDROID_LOG_WARN, LOG_TAG, __VA_ARGS__))
+#define RLOGW(...) \
+ ((void)__android_log_buf_print(LOG_ID_RADIO, ANDROID_LOG_WARN, LOG_TAG, __VA_ARGS__))
#endif
#ifndef RLOGW_IF
#define RLOGW_IF(cond, ...) \
- ( (CONDITION(cond)) \
+ ( (__predict_false(cond)) \
? ((void)__android_log_buf_print(LOG_ID_RADIO, ANDROID_LOG_WARN, LOG_TAG, __VA_ARGS__)) \
: (void)0 )
#endif
@@ -353,12 +373,13 @@ extern "C" {
* Simplified macro to send an error radio log message using the current LOG_TAG.
*/
#ifndef RLOGE
-#define RLOGE(...) ((void)__android_log_buf_print(LOG_ID_RADIO, ANDROID_LOG_ERROR, LOG_TAG, __VA_ARGS__))
+#define RLOGE(...) \
+ ((void)__android_log_buf_print(LOG_ID_RADIO, ANDROID_LOG_ERROR, LOG_TAG, __VA_ARGS__))
#endif
#ifndef RLOGE_IF
#define RLOGE_IF(cond, ...) \
- ( (CONDITION(cond)) \
+ ( (__predict_false(cond)) \
? ((void)__android_log_buf_print(LOG_ID_RADIO, ANDROID_LOG_ERROR, LOG_TAG, __VA_ARGS__)) \
: (void)0 )
#endif
@@ -374,7 +395,7 @@ extern "C" {
*/
#ifndef LOG_ALWAYS_FATAL_IF
#define LOG_ALWAYS_FATAL_IF(cond, ...) \
- ( (CONDITION(cond)) \
+ ( (__predict_false(cond)) \
? ((void)android_printAssert(#cond, LOG_TAG, ## __VA_ARGS__)) \
: (void)0 )
#endif
@@ -534,8 +555,23 @@ typedef enum {
#define android_btWriteLog(tag, type, payload, len) \
__android_log_btwrite(tag, type, payload, len)
+/*
+ * IF_ALOG uses android_testLog, but IF_ALOG can be overridden.
+ * android_testLog will remain constant in its purpose as a wrapper
+ * for Android logging filter policy, and can be subject to
+ * change. It can be reused by the developers that override
+ * IF_ALOG as a convenient means to reimplement their policy
+ * over Android.
+ */
+#if LOG_NDEBUG /* Production */
+#define android_testLog(prio, tag) \
+ (__android_log_is_loggable(prio, tag, ANDROID_LOG_DEBUG) != 0)
+#else
+#define android_testLog(prio, tag) \
+ (__android_log_is_loggable(prio, tag, ANDROID_LOG_VERBOSE) != 0)
+#endif
+
// TODO: remove these prototypes and their users
-#define android_testLog(prio, tag) (1)
#define android_writevLog(vec,num) do{}while(0)
#define android_write1Log(str,len) do{}while (0)
#define android_setMinPriority(tag, prio) do{}while(0)
@@ -546,11 +582,15 @@ typedef enum {
typedef enum log_id {
LOG_ID_MIN = 0,
+#ifndef LINT_RLOG
LOG_ID_MAIN = 0,
+#endif
LOG_ID_RADIO = 1,
+#ifndef LINT_RLOG
LOG_ID_EVENTS = 2,
LOG_ID_SYSTEM = 3,
LOG_ID_CRASH = 4,
+#endif
LOG_ID_MAX
} log_id_t;
@@ -558,6 +598,12 @@ typedef enum log_id {
#define typeof_log_id_t unsigned char
/*
+ * Use the per-tag properties "log.tag.<tagname>" to generate a runtime
+ * result of non-zero to expose a log.
+ */
+int __android_log_is_loggable(int prio, const char *tag, int def);
+
+/*
* Send a simple string to the log.
*/
int __android_log_buf_write(int bufID, int prio, const char *tag, const char *text);
diff --git a/include/log/log_read.h b/include/log/log_read.h
index 946711a..1b70aff 100644
--- a/include/log/log_read.h
+++ b/include/log/log_read.h
@@ -100,6 +100,12 @@ public:
log_time local(*this);
return local -= T;
}
+ log_time operator+= (const timespec &T);
+ log_time operator+ (const timespec &T) const
+ {
+ log_time local(*this);
+ return local += T;
+ }
// log_time
bool operator== (const log_time &T) const
@@ -134,6 +140,12 @@ public:
log_time local(*this);
return local -= T;
}
+ log_time operator+= (const log_time &T);
+ log_time operator+ (const log_time &T) const
+ {
+ log_time local(*this);
+ return local += T;
+ }
uint64_t nsec() const
{
diff --git a/include/log/logd.h b/include/log/logd.h
index 2e6f220..0fe515f 100644
--- a/include/log/logd.h
+++ b/include/log/logd.h
@@ -23,16 +23,17 @@
#include <android/log.h>
/* the rest is only used internally by the system */
-#include <time.h>
-#include <stdio.h>
-#include <unistd.h>
-#include <stdint.h>
-#include <sys/types.h>
-#ifdef HAVE_PTHREADS
+#if !defined(_WIN32)
#include <pthread.h>
#endif
-#include <log/uio.h>
#include <stdarg.h>
+#include <stdint.h>
+#include <stdio.h>
+#include <sys/types.h>
+#include <time.h>
+#include <unistd.h>
+
+#include <log/uio.h>
#ifdef __cplusplus
extern "C" {
diff --git a/include/log/logger.h b/include/log/logger.h
index 53be1d3..f030dab 100644
--- a/include/log/logger.h
+++ b/include/log/logger.h
@@ -154,6 +154,13 @@ ssize_t android_logger_get_prune_list(struct logger_list *logger_list,
int android_logger_set_prune_list(struct logger_list *logger_list,
char *buf, size_t len);
+#define ANDROID_LOG_RDONLY O_RDONLY
+#define ANDROID_LOG_WRONLY O_WRONLY
+#define ANDROID_LOG_RDWR O_RDWR
+#define ANDROID_LOG_ACCMODE O_ACCMODE
+#define ANDROID_LOG_NONBLOCK O_NONBLOCK
+#define ANDROID_LOG_PSTORE 0x80000000
+
struct logger_list *android_logger_list_alloc(int mode,
unsigned int tail,
pid_t pid);
diff --git a/include/log/logprint.h b/include/log/logprint.h
index 481c96e..1e42b47 100644
--- a/include/log/logprint.h
+++ b/include/log/logprint.h
@@ -36,6 +36,7 @@ typedef enum {
FORMAT_TIME,
FORMAT_THREADTIME,
FORMAT_LONG,
+ FORMAT_COLOR,
} AndroidLogPrintFormat;
typedef struct AndroidLogFormat_t AndroidLogFormat;
diff --git a/include/log/uio.h b/include/log/uio.h
index a71f515..7059da5 100644
--- a/include/log/uio.h
+++ b/include/log/uio.h
@@ -14,20 +14,23 @@
* limitations under the License.
*/
-//
-// implementation of sys/uio.h for platforms that don't have it (Win32)
-//
#ifndef _LIBS_CUTILS_UIO_H
#define _LIBS_CUTILS_UIO_H
-#ifdef HAVE_SYS_UIO_H
+#if !defined(_WIN32)
+
#include <sys/uio.h>
+
#else
#ifdef __cplusplus
extern "C" {
#endif
+//
+// Implementation of sys/uio.h for Win32.
+//
+
#include <stddef.h>
struct iovec {
@@ -42,7 +45,7 @@ extern int writev( int fd, const struct iovec* vecs, int count );
}
#endif
-#endif /* !HAVE_SYS_UIO_H */
+#endif
#endif /* _LIBS_UTILS_UIO_H */