2 * Copyright © 2017 Google, Inc.
4 * Permission is hereby granted, free of charge, to any person obtaining a
5 * copy of this software and associated documentation files (the "Software"),
6 * to deal in the Software without restriction, including without limitation
7 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 * and/or sell copies of the Software, and to permit persons to whom the
9 * Software is furnished to do so, subject to the following conditions:
11 * The above copyright notice and this permission notice (including the next
12 * paragraph) shall be included in all copies or substantial portions of the
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
18 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
20 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
27 #include <android/log.h>
32 #include "intel_log.h"
35 static inline android_LogPriority
36 level_to_android(enum intel_log_level l
)
39 case INTEL_LOG_ERROR
: return ANDROID_LOG_ERROR
;
40 case INTEL_LOG_WARN
: return ANDROID_LOG_WARN
;
41 case INTEL_LOG_INFO
: return ANDROID_LOG_INFO
;
42 case INTEL_LOG_DEBUG
: return ANDROID_LOG_DEBUG
;
45 unreachable("bad intel_log_level");
50 static inline const char *
51 level_to_str(enum intel_log_level l
)
54 case INTEL_LOG_ERROR
: return "error";
55 case INTEL_LOG_WARN
: return "warning";
56 case INTEL_LOG_INFO
: return "info";
57 case INTEL_LOG_DEBUG
: return "debug";
60 unreachable("bad intel_log_level");
65 intel_log(enum intel_log_level level
, const char *tag
, const char *format
, ...)
70 intel_log_v(level
, tag
, format
, va
);
75 intel_log_v(enum intel_log_level level
, const char *tag
, const char *format
,
79 __android_log_vprint(level_to_android(level
), tag
, format
, va
);
82 fprintf(stderr
, "%s: %s: ", tag
, level_to_str(level
));
83 vfprintf(stderr
, format
, va
);
84 fprintf(stderr
, "\n");