| Daniel Drown | a45056e | 2012-03-23 10:42:54 -0500 | [diff] [blame] | 1 | /* | 
 | 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 Drown | a45056e | 2012-03-23 10:42:54 -0500 | [diff] [blame] | 19 | #include <android/log.h> | 
| junyulai | c4e591a | 2018-11-26 22:36:10 +0900 | [diff] [blame] | 20 | #include <stdarg.h> | 
| Daniel Drown | a45056e | 2012-03-23 10:42:54 -0500 | [diff] [blame] | 21 |  | 
| Daniel Drown | a45056e | 2012-03-23 10:42:54 -0500 | [diff] [blame] | 22 | #include "debug.h" | 
| junyulai | c4e591a | 2018-11-26 22:36:10 +0900 | [diff] [blame] | 23 | #include "logging.h" | 
| Daniel Drown | a45056e | 2012-03-23 10:42:54 -0500 | [diff] [blame] | 24 |  | 
 | 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 |  */ | 
 | 31 | void 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 Drown | a45056e | 2012-03-23 10:42:54 -0500 | [diff] [blame] | 45 | #if CLAT_DEBUG | 
| Lorenzo Colitti | 56ec161 | 2014-03-10 16:33:22 +0900 | [diff] [blame] | 46 | void logmsg_dbg(int prio, const char *fmt, ...) { | 
| Daniel Drown | a45056e | 2012-03-23 10:42:54 -0500 | [diff] [blame] | 47 |   va_list ap; | 
 | 48 |  | 
 | 49 |   va_start(ap, fmt); | 
 | 50 |   __android_log_vprint(prio, "clatd", fmt, ap); | 
 | 51 |   va_end(ap); | 
| Daniel Drown | a45056e | 2012-03-23 10:42:54 -0500 | [diff] [blame] | 52 | } | 
| Lorenzo Colitti | 56ec161 | 2014-03-10 16:33:22 +0900 | [diff] [blame] | 53 | #else | 
 | 54 | void logmsg_dbg(__attribute__((unused)) int prio, __attribute__((unused)) const char *fmt, ...) {} | 
 | 55 | #endif |