summaryrefslogtreecommitdiffstats
path: root/liblog/logd_write.c
diff options
context:
space:
mode:
Diffstat (limited to 'liblog/logd_write.c')
-rw-r--r--liblog/logd_write.c81
1 files changed, 81 insertions, 0 deletions
diff --git a/liblog/logd_write.c b/liblog/logd_write.c
index bdee28f..9c4e481 100644
--- a/liblog/logd_write.c
+++ b/liblog/logd_write.c
@@ -323,6 +323,48 @@ const char *android_log_id_to_name(log_id_t log_id)
}
#endif
+/*
+ * Release any logger resources. A new log write will immediately re-acquire.
+ */
+void __android_log_close()
+{
+#if FAKE_LOG_DEVICE
+ int i;
+#endif
+
+#ifdef HAVE_PTHREADS
+ pthread_mutex_lock(&log_init_lock);
+#endif
+
+ write_to_log = __write_to_log_init;
+
+ /*
+ * Threads that are actively writing at this point are not held back
+ * by a lock and are at risk of dropping the messages with a return code
+ * -EBADF. Prefer to return error code than add the overhead of a lock to
+ * each log writing call to guarantee delivery. In addition, anyone
+ * calling this is doing so to release the logging resources and shut down,
+ * for them to do so with outstanding log requests in other threads is a
+ * disengenuous use of this function.
+ */
+#if FAKE_LOG_DEVICE
+ for (i = 0; i < LOG_ID_MAX; i++) {
+ fakeLogClose(log_fds[i]);
+ log_fds[i] = -1;
+ }
+#else
+ close(logd_fd);
+ logd_fd = -1;
+
+ close(pstore_fd);
+ pstore_fd = -1;
+#endif
+
+#ifdef HAVE_PTHREADS
+ pthread_mutex_unlock(&log_init_lock);
+#endif
+}
+
static int __write_to_log_init(log_id_t log_id, struct iovec *vec, size_t nr)
{
#if !defined(_WIN32)
@@ -513,3 +555,42 @@ int __android_log_bswrite(int32_t tag, const char *payload)
return write_to_log(LOG_ID_EVENTS, vec, 4);
}
+
+#ifdef MTK_HARDWARE
+struct xlog_record {
+ const char *tag_str;
+ const char *fmt_str;
+ int prio;
+};
+
+void __attribute__((weak)) __xlog_buf_printf(__unused int bufid, const struct xlog_record *xlog_record, ...) {
+ va_list args;
+ va_start(args, xlog_record);
+#if HAVE_LIBC_SYSTEM_PROPERTIES
+ int len = 0;
+ int do_xlog = 0;
+ char results[PROP_VALUE_MAX];
+
+
+ // MobileLog
+ len = __system_property_get ("debug.MB.running", results);
+ if (len && atoi(results))
+ do_xlog = 1;
+
+ // ModemLog
+ len = __system_property_get ("debug.mdlogger.Running", results);
+ if (len && atoi(results))
+ do_xlog = 1;
+
+ // Manual
+ len = __system_property_get ("persist.debug.xlog.enable", results);
+ if (len && atoi(results))
+ do_xlog = 1;
+
+ if (do_xlog > 0)
+#endif
+ __android_log_vprint(xlog_record->prio, xlog_record->tag_str, xlog_record->fmt_str, args);
+
+ return;
+}
+#endif