blob: 79d98e17937aa2910ca45bf285b35f6462d59b18 [file] [log] [blame]
Daniel Drowna45056e2012-03-23 10:42:54 -05001/*
2 * Copyright 2011 Daniel Drown
3 *
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
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
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.
15 *
16 * logging.c - print a log message
17 */
18
Daniel Drowna45056e2012-03-23 10:42:54 -050019#include <android/log.h>
junyulaic4e591a2018-11-26 22:36:10 +090020#include <stdarg.h>
Daniel Drowna45056e2012-03-23 10:42:54 -050021
Daniel Drowna45056e2012-03-23 10:42:54 -050022#include "debug.h"
junyulaic4e591a2018-11-26 22:36:10 +090023#include "logging.h"
Daniel Drowna45056e2012-03-23 10:42:54 -050024
25/* function: logmsg
26 * prints a log message to android's log buffer
27 * prio - the log message priority
28 * fmt - printf format specifier
29 * ... - printf format arguments
30 */
31void logmsg(int prio, const char *fmt, ...) {
32 va_list ap;
33
34 va_start(ap, fmt);
35 __android_log_vprint(prio, "clatd", fmt, ap);
36 va_end(ap);
37}
38
39/* function: logmsg_dbg
40 * prints a log message to android's log buffer if CLAT_DEBUG is set
41 * prio - the log message priority
42 * fmt - printf format specifier
43 * ... - printf format arguments
44 */
Daniel Drowna45056e2012-03-23 10:42:54 -050045#if CLAT_DEBUG
Lorenzo Colitti56ec1612014-03-10 16:33:22 +090046void logmsg_dbg(int prio, const char *fmt, ...) {
Daniel Drowna45056e2012-03-23 10:42:54 -050047 va_list ap;
48
49 va_start(ap, fmt);
50 __android_log_vprint(prio, "clatd", fmt, ap);
51 va_end(ap);
Daniel Drowna45056e2012-03-23 10:42:54 -050052}
Lorenzo Colitti56ec1612014-03-10 16:33:22 +090053#else
54void logmsg_dbg(__attribute__((unused)) int prio, __attribute__((unused)) const char *fmt, ...) {}
55#endif