blob: 53b2559e0a14d5ab0b3d9f312a5960ecb533edcd [file] [log] [blame]
xf.lif1aed282024-02-06 00:31:51 -08001/*
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
19#include <stdarg.h>
20#include <stdio.h>
21#include <stdlib.h>
22
23#include "logging.h"
24#include "debug.h"
25
26/* function: logmsg
27 * prints a log message to android's log buffer
28 * prio - the log message priority
29 * fmt - printf format specifier
30 * ... - printf format arguments
31 */
32void logmsg(int prio, const char *fmt, ...) {
33 va_list ap;
34 char tmp_buf[256] = {0};
35 va_start(ap, fmt);
36 //__android_log_vprint(prio, "clatd", fmt, ap);
37 vsnprintf(tmp_buf, sizeof(tmp_buf), fmt, ap);
38 printf("%s\n", tmp_buf);
39 va_end(ap);
40}
41
42/* function: logmsg_dbg
43 * prints a log message to android's log buffer if CLAT_DEBUG is set
44 * prio - the log message priority
45 * fmt - printf format specifier
46 * ... - printf format arguments
47 */
48#if CLAT_DEBUG
49void logmsg_dbg(int prio, const char *fmt, ...) {
50 va_list ap;
51 char tmp_buf[256] = {0};
52 va_start(ap, fmt);
53 //__android_log_vprint(prio, "clatd", fmt, ap);
54 vsnprintf(tmp_buf, sizeof(tmp_buf), fmt, ap);
55 printf("%s\n", tmp_buf);
56 va_end(ap);
57}
58#else
59void logmsg_dbg(__attribute__((unused)) int prio, __attribute__((unused)) const char *fmt, ...) {}
60#endif