OSDN Git Service

Distribute under Apache License v2.0
[android-x86/hardware-intel-libsensors.git] / linux / log.c
1 /*
2 // Copyright (c) 2015 Intel Corporation
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
17 #include <stdarg.h>
18 #include <syslog.h>
19
20 static int log;
21
22 int __android_log_print(int prio, const char *tag, const char *fmt, ...)
23 {
24         va_list args;
25         int loglevel;
26
27         if (!log) {
28                 openlog("android", LOG_CONS, LOG_DAEMON);
29                 log = 1;
30         }
31
32         switch (prio) {
33         default:
34         case 0:
35         case 1:
36                 loglevel = LOG_INFO;
37                 break;
38         case 2:
39         case 3:
40                 loglevel = LOG_DEBUG;
41                 break;
42         case 4:
43                 loglevel = LOG_NOTICE;
44                 break;
45         case 5:
46                 loglevel = LOG_WARNING;
47                 break;
48         case 6:
49                 loglevel = LOG_ERR;
50                 break;
51         case 7:
52                 loglevel = LOG_EMERG;
53                 break;
54         }
55
56         va_start(args, fmt);
57         vsyslog(loglevel, fmt, args);
58         va_end(args);
59
60         return 0;
61 }