Home | History | Annotate | Download | only in android-clat
      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 
     19 #include <stdarg.h>
     20 #include <android/log.h>
     21 
     22 #include "logging.h"
     23 #include "debug.h"
     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  */
     45 #if CLAT_DEBUG
     46 void logmsg_dbg(int prio, const char *fmt, ...) {
     47   va_list ap;
     48 
     49   va_start(ap, fmt);
     50   __android_log_vprint(prio, "clatd", fmt, ap);
     51   va_end(ap);
     52 }
     53 #else
     54 void logmsg_dbg(__attribute__((unused)) int prio, __attribute__((unused)) const char *fmt, ...) {}
     55 #endif
     56