summaryrefslogtreecommitdiffstats
path: root/network/netmgr/log.h
diff options
context:
space:
mode:
Diffstat (limited to 'network/netmgr/log.h')
-rw-r--r--network/netmgr/log.h45
1 files changed, 45 insertions, 0 deletions
diff --git a/network/netmgr/log.h b/network/netmgr/log.h
new file mode 100644
index 0000000..1efe72a
--- /dev/null
+++ b/network/netmgr/log.h
@@ -0,0 +1,45 @@
+/*
+ * Copyright 2018, 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.
+ */
+
+#pragma once
+
+#define LOG_TAG "netmgr"
+#include <log/log.h>
+#include <stdio.h>
+
+extern bool isTerminal;
+void initIsTerminal();
+
+// Print errors to stderr if running from a terminal, otherwise print to logcat
+// This is useful for debugging from a terminal
+#define LOGE(...) do { \
+ if (isTerminal) { \
+ fprintf(stderr, __VA_ARGS__); \
+ fprintf(stderr, "\n"); \
+ } else { \
+ ALOGE(__VA_ARGS__); \
+ } \
+} while (0)
+
+#define LOGW(...) do { \
+ if (isTerminal) { \
+ fprintf(stderr, __VA_ARGS__); \
+ fprintf(stderr, "\n"); \
+ } else { \
+ ALOGW(__VA_ARGS__); \
+ } \
+} while (0)
+