3 * Copyright (c) 2023 Samsung Electronics Co., Ltd
5 * Permission is hereby granted, free of charge, to any person obtaining a copy
6 * of this software and associated documentation files (the "Software"), to deal
7 * in the Software without restriction, including without limitation the rights
8 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 * copies of the Software, and to permit persons to whom the Software is furnished
10 * to do so, subject to the following conditions:
12 * The above copyright notice and this permission notice shall be included in all
13 * copies or substantial portions of the Software.
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 THE
18 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
23 #include <buffer_traits.h>
30 } buffer_traits[LOG_ID_MAX] = {
31 [LOG_ID_MAIN ] = { .name = "main" , .core = true, .platform = true, },
32 [LOG_ID_RADIO ] = { .name = "radio" , .core = true, .platform = true, },
33 [LOG_ID_SYSTEM] = { .name = "system", .core = true, .platform = true, },
34 [LOG_ID_APPS ] = { .name = "apps" , .core = true, .platform = false, },
35 [LOG_ID_KMSG ] = { .name = "kmsg" , .core = false, .platform = false, },
36 [LOG_ID_SYSLOG] = { .name = "syslog", .core = false, .platform = false, },
39 bool is_buffer_valid(log_id_t id)
41 return id > LOG_ID_INVALID
45 bool is_core_buffer(log_id_t id)
47 return is_buffer_valid(id) && buffer_traits[id].core;
50 bool is_platform_buffer(log_id_t id)
52 return is_buffer_valid(id) && buffer_traits[id].platform;
55 char *log_name_by_id(log_id_t id)
57 return is_buffer_valid(id) ? buffer_traits[id].name : "";
60 log_id_t log_id_by_name(const char *name)
62 for (log_id_t i = 0; i < LOG_ID_MAX; ++i)
63 if (!strcmp(name, buffer_traits[i].name))
66 return LOG_ID_INVALID;