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
25 #include <dlog-redirect-stdout.h>
28 #include <extra_sinks.h>
35 int dlog_vprint_native(log_priority prio, const char *tag, const char *fmt, va_list ap);
36 int dlog_print_native(log_priority prio, const char *tag, const char *fmt, ...);
37 int dlog_vprint_dotnet(log_priority prio, const char *tag, const char *fmt, va_list ap);
38 int dlog_print_dotnet(log_priority prio, const char *tag, const char *fmt, ...);
40 void va_stuff(log_priority prio, const char *tag, const char *fmt, ...)
45 va_list va_dotnet, va_native, va_vprint, va_iprint;
46 va_copy(va_native, va);
47 va_copy(va_dotnet, va);
48 va_copy(va_vprint, va);
49 va_copy(va_iprint, va);
51 dlog_vprint_native(prio, tag, fmt, va_native);
52 dlog_vprint_dotnet(prio, tag, fmt, va_dotnet);
53 dlog_vprint(prio, tag, fmt, va_vprint);
54 __dlog_vprint(LOG_ID_MAIN, prio, tag, fmt, va_iprint);
65 dlog_connect_fd(LOG_ID_INVALID, 1, "x", DLOG_INFO);
66 dlog_connect_fd(SINK_DOTNET , 1, "x", DLOG_INFO);
67 dlog_connect_fd(LOG_ID_MAIN , -1, "x", DLOG_INFO);
68 dlog_connect_fd(LOG_ID_MAIN , 1, NULL, DLOG_INFO);
69 dlog_connect_fd(LOG_ID_MAIN , 1, "", DLOG_INFO);
70 dlog_connect_fd(LOG_ID_MAIN , 1, "x", -999);
71 dlog_connect_fd(LOG_ID_MAIN , 1, "x", +999);
72 dlog_connect_fd(LOG_ID_MAIN , 999, "x", DLOG_INFO);
73 dlog_connect_fd(LOG_ID_MAIN , INT_MAX, "x", DLOG_INFO);
75 dlog_connect_fd(LOG_ID_MAIN , STDOUT_FILENO, "x", DLOG_INFO);
76 dlog_connect_fd(LOG_ID_RADIO , STDOUT_FILENO, "x", DLOG_INFO);
77 dlog_connect_fd(LOG_ID_SYSTEM , STDOUT_FILENO, "x", DLOG_INFO);
78 dlog_connect_fd(LOG_ID_APPS , STDOUT_FILENO, "x", DLOG_INFO);
79 dlog_connect_fd(SINK_DOTNET , STDOUT_FILENO, "x", DLOG_INFO);
80 dlog_connect_fd(SINK_NATIVE , STDOUT_FILENO, "x", DLOG_INFO);
81 dlog_connect_fd(LOG_ID_MAIN , STDERR_FILENO, "x", DLOG_INFO);
84 int const fd_null = open("/dev/null" , O_RDONLY);
85 int const fd_logs = open("/dev/log_main", O_RDONLY);
86 int const fd_else = open("/dev/kmsg" , O_RDONLY);
90 dlog_is_log_fd(fd_null);
91 dlog_is_log_fd(fd_logs);
92 dlog_is_log_fd(fd_else);
99 dlog_set_minimum_priority( -99);
100 dlog_set_minimum_priority( +99);
101 dlog_set_minimum_priority(DLOG_VERBOSE);
103 va_stuff(DLOG_ERROR, "x", "x");
105 dlog_print_native(DLOG_ERROR, "x", "x");
106 dlog_print_dotnet(DLOG_ERROR, "x", "x");
108 __dlog_print(LOG_ID_MAIN, DLOG_ERROR, "x", "x");
109 __dlog_sec_print(LOG_ID_MAIN, DLOG_ERROR, "x", "x");
110 __dlog_critical_print(LOG_ID_MAIN, DLOG_ERROR, "x", "x");
111 __dlog_print(LOG_ID_MAIN, DLOG_ERROR, "x", "x");