summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMark Salyzyn2016-03-01 15:45:42 -0600
committerMark Salyzyn2016-03-22 16:06:00 -0500
commitfacf94c74a2cc44f294c4789d36d5c7281c7bc3f (patch)
tree1568c7edb1f3f351c2fcf13d1f5ec349cd5ea26f /liblog/logger_name.c
parent5d36813dc8d3be3f62856cf5147b828a7a8594a7 (diff)
downloadplatform-system-core-facf94c74a2cc44f294c4789d36d5c7281c7bc3f.tar.gz
platform-system-core-facf94c74a2cc44f294c4789d36d5c7281c7bc3f.tar.xz
platform-system-core-facf94c74a2cc44f294c4789d36d5c7281c7bc3f.zip
liblog: split out transports into separate files
(cherry pick from commit 018a96d03f0d452bf078084eedcd5693da42308d) Create config_logger, logger and logger_read to house the log interfaces. Add fake_logger, logd_logger and pmsg_logger to house the write and read transports. Allows for an easier and direct path to add new transports to the library. SideEffects: None, logger benchmark performance unaffected Bug: 27176738 Bug: 27405083 Change-Id: I01b38637334a5242905c8c89f6ab0a92e2540008
Diffstat (limited to 'liblog/logger_name.c')
-rw-r--r--liblog/logger_name.c65
1 files changed, 65 insertions, 0 deletions
diff --git a/liblog/logger_name.c b/liblog/logger_name.c
new file mode 100644
index 000000000..b7ccac51f
--- /dev/null
+++ b/liblog/logger_name.c
@@ -0,0 +1,65 @@
1/*
2** Copyright 2013-2014, The Android Open Source Project
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 <string.h>
18
19#include <log/log.h>
20#include <log/logger.h>
21
22#include "log_portability.h"
23
24/* In the future, we would like to make this list extensible */
25static const char *LOG_NAME[LOG_ID_MAX] = {
26 [LOG_ID_MAIN] = "main",
27 [LOG_ID_RADIO] = "radio",
28 [LOG_ID_EVENTS] = "events",
29 [LOG_ID_SYSTEM] = "system",
30 [LOG_ID_CRASH] = "crash",
31 [LOG_ID_SECURITY] = "security",
32 [LOG_ID_KERNEL] = "kernel",
33};
34
35LIBLOG_ABI_PUBLIC const char *android_log_id_to_name(log_id_t log_id)
36{
37 if (log_id >= LOG_ID_MAX) {
38 log_id = LOG_ID_MAIN;
39 }
40 return LOG_NAME[log_id];
41}
42
43LIBLOG_ABI_PUBLIC log_id_t android_name_to_log_id(const char *logName)
44{
45 const char *b;
46 int ret;
47
48 if (!logName) {
49 return -1; /* NB: log_id_t is unsigned */
50 }
51 b = strrchr(logName, '/');
52 if (!b) {
53 b = logName;
54 } else {
55 ++b;
56 }
57
58 for(ret = LOG_ID_MIN; ret < LOG_ID_MAX; ++ret) {
59 const char *l = LOG_NAME[ret];
60 if (l && !strcmp(b, l)) {
61 return ret;
62 }
63 }
64 return -1; /* should never happen */
65}