summaryrefslogtreecommitdiffstats
path: root/include/log
diff options
context:
space:
mode:
Diffstat (limited to 'include/log')
-rw-r--r--include/log/log.h23
-rw-r--r--include/log/log_read.h79
-rw-r--r--include/log/logger.h131
-rw-r--r--include/log/uio.h6
4 files changed, 205 insertions, 34 deletions
diff --git a/include/log/log.h b/include/log/log.h
index 7faddea..7f952ff 100644
--- a/include/log/log.h
+++ b/include/log/log.h
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2005 The Android Open Source Project
+ * Copyright (C) 2005-2014 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -28,17 +28,16 @@
#ifndef _LIBS_LOG_LOG_H
#define _LIBS_LOG_LOG_H
-#include <stdio.h>
-#include <time.h>
#include <sys/types.h>
-#include <unistd.h>
#ifdef HAVE_PTHREADS
#include <pthread.h>
#endif
#include <stdarg.h>
-
-#include <log/uio.h>
+#include <stdio.h>
+#include <time.h>
+#include <unistd.h>
#include <log/logd.h>
+#include <log/uio.h>
#ifdef __cplusplus
extern "C" {
@@ -470,7 +469,8 @@ typedef enum {
EVENT_TYPE_STRING = 2,
EVENT_TYPE_LIST = 3,
} AndroidEventLogType;
-
+#define sizeof_AndroidEventLogType sizeof(typeof_AndroidEventLogType)
+#define typeof_AndroidEventLogType unsigned char
#ifndef LOG_EVENT_INT
#define LOG_EVENT_INT(_tag, _value) { \
@@ -540,7 +540,9 @@ typedef enum {
#define android_logToFile(tag, file) (0)
#define android_logToFd(tag, fd) (0)
-typedef enum {
+typedef enum log_id {
+ LOG_ID_MIN = 0,
+
LOG_ID_MAIN = 0,
LOG_ID_RADIO = 1,
LOG_ID_EVENTS = 2,
@@ -548,6 +550,8 @@ typedef enum {
LOG_ID_MAX
} log_id_t;
+#define sizeof_log_id_t sizeof(typeof_log_id_t)
+#define typeof_log_id_t unsigned char
/*
* Send a simple string to the log.
@@ -555,9 +559,8 @@ typedef enum {
int __android_log_buf_write(int bufID, int prio, const char *tag, const char *text);
int __android_log_buf_print(int bufID, int prio, const char *tag, const char *fmt, ...);
-
#ifdef __cplusplus
}
#endif
-#endif // _LIBS_CUTILS_LOG_H
+#endif /* _LIBS_LOG_LOG_H */
diff --git a/include/log/log_read.h b/include/log/log_read.h
new file mode 100644
index 0000000..861c192
--- /dev/null
+++ b/include/log/log_read.h
@@ -0,0 +1,79 @@
+/*
+ * Copyright (C) 2013-2014 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef _LIBS_LOG_LOG_READ_H
+#define _LIBS_LOG_LOG_READ_H
+
+#include <time.h>
+
+#define NS_PER_SEC 1000000000ULL
+#ifdef __cplusplus
+struct log_time : public timespec {
+public:
+ log_time(timespec &T)
+ {
+ tv_sec = T.tv_sec;
+ tv_nsec = T.tv_nsec;
+ }
+ log_time(void)
+ {
+ }
+ log_time(clockid_t id)
+ {
+ clock_gettime(id, (timespec *) this);
+ }
+ log_time(const char *T)
+ {
+ const uint8_t *c = (const uint8_t *) T;
+ tv_sec = c[0] | (c[1] << 8) | (c[2] << 16) | (c[3] << 24);
+ tv_nsec = c[4] | (c[5] << 8) | (c[6] << 16) | (c[7] << 24);
+ }
+ bool operator== (const timespec &T) const
+ {
+ return (tv_sec == T.tv_sec) && (tv_nsec == T.tv_nsec);
+ }
+ bool operator!= (const timespec &T) const
+ {
+ return !(*this == T);
+ }
+ bool operator< (const timespec &T) const
+ {
+ return (tv_sec < T.tv_sec)
+ || ((tv_sec == T.tv_sec) && (tv_nsec < T.tv_nsec));
+ }
+ bool operator>= (const timespec &T) const
+ {
+ return !(*this < T);
+ }
+ bool operator> (const timespec &T) const
+ {
+ return (tv_sec > T.tv_sec)
+ || ((tv_sec == T.tv_sec) && (tv_nsec > T.tv_nsec));
+ }
+ bool operator<= (const timespec &T) const
+ {
+ return !(*this > T);
+ }
+ uint64_t nsec(void) const
+ {
+ return static_cast<uint64_t>(tv_sec) * NS_PER_SEC + tv_nsec;
+ }
+};
+#else
+typedef struct timespec log_time;
+#endif
+
+#endif /* define _LIBS_LOG_LOG_READ_H */
diff --git a/include/log/logger.h b/include/log/logger.h
index 04f3fb0..966397a 100644
--- a/include/log/logger.h
+++ b/include/log/logger.h
@@ -1,16 +1,21 @@
-/* utils/logger.h
-**
-** Copyright 2007, The Android Open Source Project
+/*
+**
+** Copyright 2007-2014, The Android Open Source Project
**
** This file is dual licensed. It may be redistributed and/or modified
** under the terms of the Apache 2.0 License OR version 2 of the GNU
** General Public License.
*/
-#ifndef _UTILS_LOGGER_H
-#define _UTILS_LOGGER_H
+#ifndef _LIBS_LOG_LOGGER_H
+#define _LIBS_LOG_LOGGER_H
#include <stdint.h>
+#include <log/log.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
/*
* The userspace structure for version 1 of the logger_entry ABI.
@@ -43,11 +48,6 @@ struct logger_entry_v2 {
char msg[0]; /* the entry's payload */
};
-#define LOGGER_LOG_MAIN "log/main"
-#define LOGGER_LOG_RADIO "log/radio"
-#define LOGGER_LOG_EVENTS "log/events"
-#define LOGGER_LOG_SYSTEM "log/system"
-
/*
* The maximum size of the log entry payload that can be
* written to the kernel logger driver. An attempt to write
@@ -63,19 +63,108 @@ struct logger_entry_v2 {
*/
#define LOGGER_ENTRY_MAX_LEN (5*1024)
-#ifdef HAVE_IOCTL
+#define NS_PER_SEC 1000000000ULL
+
+struct log_msg {
+ union {
+ unsigned char buf[LOGGER_ENTRY_MAX_LEN + 1];
+ struct logger_entry_v2 entry;
+ struct logger_entry_v2 entry_v2;
+ struct logger_entry entry_v1;
+ struct {
+ unsigned char buf[LOGGER_ENTRY_MAX_LEN + 1];
+ log_id_t id;
+ } extra;
+ } __attribute__((aligned(4)));
+#ifdef __cplusplus
+ /* Matching log_time operators */
+ bool operator== (const log_msg &T) const
+ {
+ return (entry.sec == T.entry.sec) && (entry.nsec == T.entry.nsec);
+ }
+ bool operator!= (const log_msg &T) const
+ {
+ return !(*this == T);
+ }
+ bool operator< (const log_msg &T) const
+ {
+ return (entry.sec < T.entry.sec)
+ || ((entry.sec == T.entry.sec)
+ && (entry.nsec < T.entry.nsec));
+ }
+ bool operator>= (const log_msg &T) const
+ {
+ return !(*this < T);
+ }
+ bool operator> (const log_msg &T) const
+ {
+ return (entry.sec > T.entry.sec)
+ || ((entry.sec == T.entry.sec)
+ && (entry.nsec > T.entry.nsec));
+ }
+ bool operator<= (const log_msg &T) const
+ {
+ return !(*this > T);
+ }
+ uint64_t nsec(void) const
+ {
+ return static_cast<uint64_t>(entry.sec) * NS_PER_SEC + entry.nsec;
+ }
+
+ /* packet methods */
+ log_id_t id(void)
+ {
+ return extra.id;
+ }
+ char *msg(void)
+ {
+ return entry.hdr_size ? (char *) buf + entry.hdr_size : entry_v1.msg;
+ }
+ unsigned int len(void)
+ {
+ return (entry.hdr_size ? entry.hdr_size : sizeof(entry_v1)) + entry.len;
+ }
+#endif
+};
-#include <sys/ioctl.h>
+struct logger;
-#define __LOGGERIO 0xAE
+log_id_t android_logger_get_id(struct logger *logger);
-#define LOGGER_GET_LOG_BUF_SIZE _IO(__LOGGERIO, 1) /* size of log */
-#define LOGGER_GET_LOG_LEN _IO(__LOGGERIO, 2) /* used log len */
-#define LOGGER_GET_NEXT_ENTRY_LEN _IO(__LOGGERIO, 3) /* next entry len */
-#define LOGGER_FLUSH_LOG _IO(__LOGGERIO, 4) /* flush log */
-#define LOGGER_GET_VERSION _IO(__LOGGERIO, 5) /* abi version */
-#define LOGGER_SET_VERSION _IO(__LOGGERIO, 6) /* abi version */
+int android_logger_clear(struct logger *logger);
+int android_logger_get_log_size(struct logger *logger);
+int android_logger_get_log_readable_size(struct logger *logger);
+int android_logger_get_log_version(struct logger *logger);
+
+struct logger_list;
+
+struct logger_list *android_logger_list_alloc(int mode,
+ unsigned int tail,
+ pid_t pid);
+void android_logger_list_free(struct logger_list *logger_list);
+/* In the purest sense, the following two are orthogonal interfaces */
+int android_logger_list_read(struct logger_list *logger_list,
+ struct log_msg *log_msg);
+
+/* Multiple log_id_t opens */
+struct logger *android_logger_open(struct logger_list *logger_list,
+ log_id_t id);
+#define android_logger_close android_logger_free
+/* Single log_id_t open */
+struct logger_list *android_logger_list_open(log_id_t id,
+ int mode,
+ unsigned int tail,
+ pid_t pid);
+#define android_logger_list_close android_logger_list_free
+
+/*
+ * log_id_t helpers
+ */
+log_id_t android_name_to_log_id(const char *logName);
+const char *android_log_id_to_name(log_id_t log_id);
-#endif // HAVE_IOCTL
+#ifdef __cplusplus
+}
+#endif
-#endif /* _UTILS_LOGGER_H */
+#endif /* _LIBS_LOG_LOGGER_H */
diff --git a/include/log/uio.h b/include/log/uio.h
index 01a74d2..a71f515 100644
--- a/include/log/uio.h
+++ b/include/log/uio.h
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2007 The Android Open Source Project
+ * Copyright (C) 2007-2014 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -31,8 +31,8 @@ extern "C" {
#include <stddef.h>
struct iovec {
- const void* iov_base;
- size_t iov_len;
+ void* iov_base;
+ size_t iov_len;
};
extern int readv( int fd, struct iovec* vecs, int count );