1 /* Copyright (c) 2020, Samsung Electronics Co., Ltd. All rights reserved.
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at
7 * http://www.apache.org/licenses/LICENSE-2.0
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License. */
24 #include <logconfig.h>
25 #include <loglimiter.h>
27 int wtl(log_id_t buf_id, log_priority pri, const char *tag, const char *msg, struct timespec *tp_mono) { return 0xABCD; }
28 void __dlog_init_pipe(const struct log_config *conf) { write_to_log = wtl; }
30 int __wrap_log_config_read(struct log_config *config)
32 config->begin = config->last = NULL;
33 log_config_set(config, "backend", "pipe");
34 log_config_set(config, "debugmode", "1");
38 // lobotomize various mechanisms I don't want to deal with
39 void __log_limiter_update(const struct log_config *config) { }
40 void __log_limiter_destroy(void) { }
41 void __dynamic_config_destroy() { }
42 struct pass_log_result __log_limiter_pass_log(const char *tag, int prio) { return (struct pass_log_result) { .decision = DECISION_ALLOWED }; }
43 int __log_limiter_create(const struct log_config *config) { return 1; }
44 bool __dynamic_config_create(struct log_config *config) { return false; }
45 void __dynamic_config_update() { }
46 void __dlog_init_android(const struct log_config *conf) { }
51 #define VALID_FILTER(x) assert(dlog_set_minimum_priority(x) == DLOG_ERROR_NONE)
52 #define INVALID_FILTER(x) assert(dlog_set_minimum_priority(x) == DLOG_ERROR_INVALID_PARAMETER)
53 #define ALLOW(x) assert(__dlog_print(LOG_ID_MAIN, x, "tag", "msg") == 0xABCD)
54 #define BLOCK(x) assert(__dlog_print(LOG_ID_MAIN, x, "tag", "msg") == 0)
56 // Nothing should be filtered if there hasn't been a minimum set
57 for (int p = DLOG_VERBOSE; p < DLOG_PRIO_MAX; ++p)
60 // The DEFAULT level should also not filter anything
61 VALID_FILTER(DLOG_DEFAULT);
62 for (int p = DLOG_VERBOSE; p < DLOG_PRIO_MAX; ++p)
65 // The MAX filter should filter everything.
66 VALID_FILTER(DLOG_PRIO_MAX);
67 for (int p = DLOG_VERBOSE; p <= DLOG_SILENT; ++p)
70 for (int l = DLOG_VERBOSE; l < DLOG_PRIO_MAX; ++l) {
72 for (int p = DLOG_VERBOSE; p < DLOG_PRIO_MAX; ++p)
80 INVALID_FILTER(DLOG_UNKNOWN);
82 // Adjacent to the allowed values
83 INVALID_FILTER(DLOG_DEFAULT - 1);
84 INVALID_FILTER(DLOG_PRIO_MAX + 1);
86 // Misc arbitrary values
87 INVALID_FILTER((log_priority) -1);
88 INVALID_FILTER((log_priority) 0);
89 INVALID_FILTER((log_priority) 57);