2 * Copyright (C) 2005-2014 The Android Open Source Project
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
19 /* Too many in the ecosystem assume these are included */
23 #include <stdint.h> /* uint16_t, int32_t */
28 #include <android/log.h>
29 #include <log/log_id.h>
30 #include <log/log_main.h>
31 #include <log/log_radio.h>
32 #include <log/log_safetynet.h>
33 #include <log/log_system.h>
34 #include <log/log_time.h>
41 * LOG_TAG is the local tag used for the following simplified
42 * logging macros. You can change this preprocessor definition
43 * before using the other macros to change the tag.
51 * Normally we strip the effects of ALOGV (VERBOSE messages),
52 * LOG_FATAL and LOG_FATAL_IF (FATAL assert messages) from the
53 * release builds be defining NDEBUG. You can modify this (for
54 * example with "#define LOG_NDEBUG 0" at the top of your source
55 * file) to change that behavior.
67 * The maximum size of the log entry payload that can be
68 * written to the logger. An attempt to write more than
69 * this amount will result in a truncated log entry.
71 #define LOGGER_ENTRY_MAX_PAYLOAD 4068
78 * The following should not be used directly.
81 int __android_log_bwrite(int32_t tag
, const void* payload
, size_t len
);
82 int __android_log_btwrite(int32_t tag
, char type
, const void* payload
,
84 int __android_log_bswrite(int32_t tag
, const char* payload
);
86 int __android_log_stats_bwrite(int32_t tag
, const void* payload
, size_t len
);
88 #define android_bWriteLog(tag, payload, len) \
89 __android_log_bwrite(tag, payload, len)
90 #define android_btWriteLog(tag, type, payload, len) \
91 __android_log_btwrite(tag, type, payload, len)
94 * Event log entry types.
97 /* Special markers for android_log_list_element type */
98 EVENT_TYPE_LIST_STOP
= '\n', /* declare end of list */
99 EVENT_TYPE_UNKNOWN
= '?', /* protocol error */
101 /* must match with declaration in java/android/android/util/EventLog.java */
102 EVENT_TYPE_INT
= 0, /* int32_t */
103 EVENT_TYPE_LONG
= 1, /* int64_t */
104 EVENT_TYPE_STRING
= 2,
106 EVENT_TYPE_FLOAT
= 4,
107 } AndroidEventLogType
;
109 #ifndef LOG_EVENT_INT
110 #define LOG_EVENT_INT(_tag, _value) \
112 int intBuf = _value; \
113 (void)android_btWriteLog(_tag, EVENT_TYPE_INT, &intBuf, sizeof(intBuf)); \
116 #ifndef LOG_EVENT_LONG
117 #define LOG_EVENT_LONG(_tag, _value) \
119 long long longBuf = _value; \
120 (void)android_btWriteLog(_tag, EVENT_TYPE_LONG, &longBuf, sizeof(longBuf)); \
123 #ifndef LOG_EVENT_FLOAT
124 #define LOG_EVENT_FLOAT(_tag, _value) \
126 float floatBuf = _value; \
127 (void)android_btWriteLog(_tag, EVENT_TYPE_FLOAT, &floatBuf, \
131 #ifndef LOG_EVENT_STRING
132 #define LOG_EVENT_STRING(_tag, _value) \
133 (void)__android_log_bswrite(_tag, _value);
136 /* --------------------------------------------------------------------- */
139 * Release any logger resources (a new log write will immediately re-acquire)
141 * This is specifically meant to be used by Zygote to close open file descriptors after fork()
142 * and before specialization. O_CLOEXEC is used on file descriptors, so they will be closed upon
143 * exec() in normal use cases.
145 * Note that this is not safe to call from a multi-threaded program.
147 void __android_log_close(void);