3 * Copyright (c) 2012-2020 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
38 #include "deduplicate.h"
39 #include <dynamic_config.h>
41 #include <logcommon.h>
42 #include "logconfig.h"
43 #include "loglimiter.h"
45 #define DEFAULT_CONFIG_LIMITER false
46 #define DEFAULT_CONFIG_PLOG true
47 #define DEFAULT_CONFIG_DEBUGMODE 0
48 #define DEFAULT_CONFIG_LIMITER_APPLY_TO_ALL_BUFFERS 0
51 * @brief Points to a function which writes a log message
52 * @details The function pointed to depends on the backend used
53 * @param[in] log_id ID of the buffer to log to. Belongs to (LOG_ID_INVALID, LOG_ID_MAX) non-inclusive
54 * @param[in] prio Priority of the message.
55 * @param[in] tag The message tag, identifies the sender.
56 * @param[in] msg The contents of the message.
57 * @return Returns the number of bytes written on success and a negative error value on error.
58 * @see __dlog_init_backend
60 int (*write_to_log)(log_id_t log_id, log_priority prio, const char *tag, const char *msg, struct timespec *tp_mono) = NULL;
61 void (*destroy_backend)(void);
63 int (*stash_failed_log)(log_id_t log_id, log_priority prio, const char *tag, const char *msg) = NULL;
65 static int stash_critical(log_id_t log_id, log_priority prio, const char *tag, const char *msg);
68 pthread_rwlock_t log_limiter_lock = PTHREAD_RWLOCK_INITIALIZER;
69 static pthread_mutex_t log_construction_lock = PTHREAD_MUTEX_INITIALIZER;
70 static bool is_initialized = false;
72 extern void __dlog_init_pipe(const struct log_config *conf);
73 extern void __dlog_init_android(const struct log_config *conf);
76 struct limiter_data *limiter_data;
77 static bool dynamic_config;
78 static bool plog[LOG_ID_MAX];
79 static bool plog_default_values[LOG_ID_MAX];
80 static bool enable_secure_logs = true;
81 static bool enable_critical = true;
84 static int fatal_assert;
85 static int limiter_apply_to_all_buffers;
86 static _Atomic log_priority priority_filter_level = DLOG_VERBOSE;
88 /* Here, static_config is the original config from /etc/dlog.conf{,.d} which can be overriden,
89 * but comes back if the override is removed. both_config additionally contains dynamic rules
90 * (by default from /run/dlog/filters.d) which can be changed in the runtime.
91 * The static_config has to be kept separately, so that we can go back to it when dynamic rules change.
92 * Note that most functions only use static_config, since the parameters can't be changed in runtime. */
93 static void __configure_limiter(struct log_config *static_config, struct log_config *both_config)
95 assert(static_config);
102 limiter_data = __log_limiter_create(static_config);
103 if (limiter_data && dynamic_config)
104 __log_limiter_update(limiter_data, both_config);
105 limiter = (bool)limiter_data;
108 static int __configure_backend(struct log_config *config)
112 const char *const backend = log_config_get(config, "backend");
116 if (!strcmp(backend, "pipe"))
117 __dlog_init_pipe(config);
118 else if (!strcmp(backend, "logger"))
119 __dlog_init_android(config);
126 static void __set_plog_default_values(void)
128 for (size_t i = 0; i < NELEMS(plog); ++i)
129 plog_default_values[i] = plog[i];
132 static void __initialize_plog(const struct log_config *config)
136 const bool plog_default = log_config_get_boolean(config, "plog", DEFAULT_CONFIG_PLOG);
137 for (size_t i = 0; i < NELEMS(plog); ++i)
138 plog[i] = plog_default;
139 plog[LOG_ID_APPS] = true; // the default does not apply here for backward compatibility reasons.
140 __set_plog_default_values();
143 static void __configure_parameters(struct log_config *static_config, struct log_config *both_config)
145 assert(static_config);
148 __initialize_plog(static_config);
149 __update_plog(static_config);
150 /* Like in __configure_limiter, we also check the dynamic rules. However, we make sure to
151 * set the default values to the ones generated by the static rules first. */
152 __set_plog_default_values();
153 __update_plog(both_config);
155 enable_secure_logs = log_config_get_boolean(both_config, "enable_secure_logs", enable_secure_logs);
156 enable_critical = log_config_get_boolean(both_config, "enable_critical", enable_critical);
157 debugmode = log_config_get_int(both_config, "debugmode", DEFAULT_CONFIG_DEBUGMODE);
158 fatal_assert = access(DEBUGMODE_FILE, F_OK) != -1;
159 limiter = log_config_get_boolean(both_config, "limiter", DEFAULT_CONFIG_LIMITER);
160 limiter_apply_to_all_buffers = log_config_get_int(both_config,
161 "limiter_apply_to_all_buffers",
162 DEFAULT_CONFIG_LIMITER_APPLY_TO_ALL_BUFFERS);
164 const char *stash_failed_log_method = log_config_get(both_config, "stash_failed_log_method");
165 if (stash_failed_log_method) {
167 if (strcmp(stash_failed_log_method, "critical") == 0)
168 stash_failed_log = stash_critical;
173 void __update_plog(const struct log_config *conf)
177 for (size_t i = 0; i < NELEMS(plog); ++i) {
178 char key[MAX_CONF_KEY_LEN];
179 const int r = snprintf(key, sizeof key, "enable_%s", log_name_by_id((log_id_t)i));
182 plog[i] = log_config_get_boolean(conf, key, plog_default_values[i]);
187 * @brief Configure the library
188 * @details Reads relevant config values
189 * @remarks This is more or less a constructor, but there are some obstacles
190 * to using it as such (i.e. with attribute constructor):
192 * - some important pieces of the system link to dlog, they start very early
193 * such that dlog can't properly initialize (which lasts for program lifetime)
194 * but don't actually log anything until later on and would be fine under lazy
195 * initialisation. The way to do it "properly" would be to expose this function
196 * into the API so that people can manually call it when they're ready, but
197 * one of the design goals of the current API is that it requires absolutely no
198 * other calls than `dlog_print`. Changing it would require somebody with a
199 * bird's eye view of the system to produce a design so I wouldn't count on it.
201 * - the constructor would need to have as high of a priority as possible (so as
202 * to minimize the risk of another library's constructor using uninitialized data)
203 * but at the same time others might want some room to wrap functions before
204 * dlog uses them (think mprobe/mcheck). This would also require a design pass.
209 bool __configure(void)
211 __attribute__((cleanup(log_config_free))) struct log_config static_config = {};
212 __attribute__((cleanup(log_config_free))) struct log_config both_config = {};
214 if (log_config_read(&static_config) < 0)
216 log_config_copy(&both_config, &static_config);
218 dynamic_config = __dynamic_config_create(&both_config);
220 __configure_parameters(&static_config, &both_config);
222 if (!__configure_backend(&both_config)) {
223 __dynamic_config_destroy();
224 dynamic_config = false;
228 __configure_deduplicate(&both_config);
229 __configure_limiter(&static_config, &both_config);
233 static void __attribute__((constructor(101))) __install_pipe_handler(void)
235 /* We mask SIGPIPE signal because most applications do not install their
236 * own SIGPIPE handler. Default behaviour in SIGPIPE case is to abort the
237 * process. SIGPIPE occurs when e.g. dlog daemon closes read pipe endpoint.
239 * We do this in the library constructor (at maximum priority) and not
240 * during regular (lazy) initialisation so as to prevent overwriting the
241 * program's actual signal handler, if it has one.
243 * In theory this is not required for the Android logger backend; however,
244 * this early we don't yet know the backend and also it is good to behave
245 * consistently in this regard anyway.
247 * We don't revert this in a destructor because Unix signals are bonkers
248 * and we have no way to do this cleanly. Most libdlog users don't use
249 * runtime linking so this would mostly done at program exit either way. */
250 signal(SIGPIPE, SIG_IGN);
253 static void __attribute__((constructor(102))) __set_output_buffering(void)
255 /* If stdout and/or stderr is redirected to dlog (service, driver)
256 * it is best if we buffer lines, otherwise the following can happen:
257 * - no buffering: service/driver recives every single byte (precisely
258 * every single write*(2) call), causing it to either buffer the data
259 * anyway (service), or print logs at random places (driver)
260 * - full buffering: service/driver receives several hundred lines,
261 * which results in one giant entry being added (driver) or long delays
262 * before logs appear (service) */
263 if (getenv(DLOG_ENV_STDOUT_LINE_BUFFERED))
266 if (getenv(DLOG_ENV_STDERR_LINE_BUFFERED))
270 static bool first = true;
271 static bool initialize(void)
276 /* The mutex acts as a barrier, but otherwise the C language's
277 * machine abstraction is single-threaded. This means that the
278 * compiler is free to rearrange calls inside the mutex according
279 * to the as-if rule because it doesn't care if another thread can
280 * access it in parallel. In particular, `is_initialized = true`
281 * directly after `__configure()` could be rearranged to go in
282 * front of it because it is not touched inside that function
283 * if the compiler thinks it helps somehow (not unlikely: since
284 * it is checked before the mutex, it is very probable for it to
285 * still be in the CPU register or something like that). On top
286 * of that, some architectures (in particular, armv7l) don't have
287 * strict memory guarantees and can reorder actual memory stores
288 * on their own, even if the compiler didn't do anything fancy
289 * when creating machine code. For more info about the issue,
290 * see https://www.aristeia.com/Papers/DDJ_Jul_Aug_2004_revised.pdf
292 * Ultimately this means that there needs to be some sort of
293 * barrier between `__configure` and `is_initialized = true`,
294 * and the simplest way to achieve that is to just wait until
295 * the second entry into the mutex. */
298 pthread_mutex_lock(&log_construction_lock);
300 first = !__configure();
302 is_initialized = true;
304 pthread_mutex_unlock(&log_construction_lock);
309 * @brief Fatal assertion
310 * @details Conditionally crash the sucka who sent the log
311 * @param[in] prio Priority of the log
313 static void __dlog_fatal_assert(int prio)
315 assert(!fatal_assert || (prio != DLOG_FATAL));
319 * @brief Check log validity
320 * @details Checks whether the log is valid and eligible for printing
321 * @param[in] log_id The target buffer ID
322 * @param[in] prio The log's priority
323 * @param[in] tag The log's tag
324 * @return DLOG_ERROR_NONE on success, else an error code.
325 * @retval DLOG_ERROR_INVALID_PARAMETER Invalid parameter
327 static int dlog_check_validity(log_id_t log_id, int prio, const char *tag)
331 return DLOG_ERROR_INVALID_PARAMETER;
333 if (log_id <= LOG_ID_INVALID || LOG_ID_MAX <= log_id)
334 return DLOG_ERROR_INVALID_PARAMETER;
336 return DLOG_ERROR_NONE;
340 * @brief Check log against limiter rules
341 * @details Checks whether the log passes current limiter rules
342 * @param[in] log_id The target buffer ID
343 * @param[in] prio The log's priority
344 * @param[in] tag The log's tag
345 * @return DLOG_ERROR_NONE on success, else an error code.
346 * @retval DLOG_ERROR_NOT_PERMITTED Not permitted
348 static int dlog_check_limiter(log_id_t log_id, int prio, const char *tag)
350 if (!debugmode && prio <= DLOG_DEBUG)
351 return DLOG_ERROR_NOT_PERMITTED;
354 __dynamic_config_update(limiter_data);
357 struct pass_log_result should_log = { .decision = DECISION_DENIED };
358 if (!pthread_rwlock_rdlock(&log_limiter_lock)) {
359 should_log = __log_limiter_pass_log(limiter_data, tag, prio);
360 pthread_rwlock_unlock(&log_limiter_lock);
363 switch (should_log.decision) {
364 case DECISION_DENIED:
365 return DLOG_ERROR_NOT_PERMITTED;
367 case DECISION_TAG_LIMIT_EXCEEDED_MESSAGE:
368 case DECISION_PID_LIMIT_EXCEEDED_MESSAGE: {
370 int result = clock_gettime(CLOCK_MONOTONIC, &tp);
372 return DLOG_ERROR_NOT_PERMITTED;
374 snprintf(buf, sizeof(buf),
375 "Your log has been blocked due to per-%s limit of %d logs per %d seconds.",
376 should_log.decision == DECISION_TAG_LIMIT_EXCEEDED_MESSAGE ? "tag" : "PID",
377 should_log.logs_per_period, should_log.period_s);
378 write_to_log(log_id, prio, tag, buf, &tp);
379 return DLOG_ERROR_NOT_PERMITTED;
382 case DECISION_ALLOWED:
387 /* This can change due to __dynamic_config_update(), but is atomic and its
388 * value implies nothing else so does not need to be under a lock. */
390 return DLOG_ERROR_NOT_PERMITTED;
392 return DLOG_ERROR_NONE;
395 static int __write_to_log_critical_section(log_id_t log_id, int prio, const char *tag, const char *fmt, va_list ap, bool check_should_log)
397 if (check_should_log && prio < priority_filter_level)
398 return DLOG_ERROR_NONE;
400 if ((check_should_log || limiter_apply_to_all_buffers) && (dlog_check_limiter(log_id, prio, tag) < 0))
401 return DLOG_ERROR_NONE;
403 char buf[LOG_MAX_PAYLOAD_SIZE];
404 int len = vsnprintf(buf, sizeof buf, fmt, ap);
406 return DLOG_ERROR_NONE;
407 else if (len >= sizeof buf)
408 len = sizeof buf - 1;
412 if (deduplicate_func && !clock_gettime(CLOCK_MONOTONIC, &tp)) {
413 dlog_deduplicate_e ret = deduplicate_func(buf, len, &tp);
414 if (ret == DLOG_DEDUPLICATE)
415 return DLOG_ERROR_NONE;
416 else if (ret == DLOG_DO_NOT_DEDUPLICATE_BUT_WARN)
417 deduplicate_warn(buf, sizeof buf, len);
418 r = write_to_log(log_id, prio, tag, buf, &tp);
420 r = write_to_log(log_id, prio, tag, buf, NULL);
422 if (r < 0 && stash_failed_log)
423 r = stash_failed_log(log_id, prio, tag, buf);
428 static int __write_to_log(log_id_t log_id, int prio, const char *tag, const char *fmt, va_list ap, bool check_should_log, bool secure_log)
430 int ret = dlog_check_validity(log_id, prio, tag);
434 /* Threads can be cancelled before they give up a lock.
435 * Therefore cancellation is temporarily disabled.
436 * This solution is comparatively simple and cheap.
437 * The other solutions (cleanup handlers, robust mutexes)
438 * would be much more complicated and also inflict larger
439 * runtime costs. The downside of disabling cancellation
440 * is not a problem in our case because it is temporary
441 * and very brief so we don't keep an obsolete thread
442 * for much longer than we otherwise would. */
443 int old_cancel_state;
444 pthread_setcancelstate(PTHREAD_CANCEL_DISABLE, &old_cancel_state);
446 /* The only thing that needs to be protected here is `write_to_log` since
447 * all other resources already have their own specific locks (and even the
448 * pointer could be made to point at a null handler instead of a true NULL)
449 * but giving this guarantee makes everything a lot simpler as it removes
450 * the risk of something suddenly becoming NULL during processing. */
451 if (!initialize() || !write_to_log)
452 // TODO: We could consider stashing the failed log here
453 ret = DLOG_ERROR_NOT_PERMITTED;
454 else if (secure_log && !enable_secure_logs)
457 ret = __write_to_log_critical_section(log_id, prio, tag, fmt, ap, check_should_log);
459 pthread_setcancelstate(old_cancel_state, NULL);
464 int __critical_log_append_timestamp(char *buf, size_t buflen)
466 /* NB: the timestamp may slightly differ from the one that gets
467 * added onto the copy that goes into the regular buffer, and
468 * timestamp acquisition is duplicated. This would ideally be
469 * solved, but timestamps are currently added fairly deep in
470 * backend-specific functions so for now this will have to do.
471 * Also, since we're the sender, there is just this one set of
472 * timestamps, i.e. the send timestamp! The usual alternative
473 * set of receive timestamps will never have the opportunity
474 * to get added to the entry since this log is supposed to end
475 * up straight in the file (there's potentially the trusted
476 * writer binary but we're trying to keep the set of actions
477 * it needs to do to the minimum and those timestamps would
478 * in practice be the same anyway). */
481 clock_gettime(CLOCK_REALTIME, &ts);
482 const time_t tt = ts.tv_sec;
483 const long int real_millisec = ts.tv_nsec / 1000000;
484 clock_gettime(CLOCK_MONOTONIC, &ts);
486 struct tm *const ptm = localtime_r(&tt, &tmBuf);
487 assert(ptm); // we're in a short lived fork so asserts are fine and make things simple
489 int len = strftime(buf, buflen, "%m-%d %H:%M:%S", ptm);
492 int tmp_len = snprintf(buf + len, buflen - len, ".%03ld", real_millisec);
494 assert(tmp_len < buflen - len);
497 tmp_len = strftime(buf + len, buflen - len, "%z ", ptm);
498 assert(tmp_len != 0);
501 tmp_len = snprintf(buf + len, buflen - len, "%5lu.%03ld", ts.tv_sec, ts.tv_nsec / 1000000);
503 assert(tmp_len < buflen - len);
509 int __critical_log_build_msg(char *buf, size_t buflen, pid_t main_pid, pid_t main_tid, log_id_t log_id, int prio, const char *tag, const char *fmt, va_list ap)
511 int len = __critical_log_append_timestamp(buf, buflen);
512 const int metadata_len = snprintf(buf + len, buflen - len, " P%5d T%5d B%-6s %c/%-8s: ",
515 log_name_by_id(log_id),
516 filter_pri_to_char(prio),
517 tag ?: "CRITICAL_NO_TAG");
518 assert(metadata_len > 0);
519 if (metadata_len >= buflen - len)
520 return buflen - 1; // can genuinely happen with an exceedingly large tag
523 const int content_len = vsnprintf(buf + len, buflen - len, fmt, ap);
524 assert(content_len >= 0); // 0 is legit with format == ""
525 if (content_len >= buflen - len)
533 __attribute__ ((noreturn))
535 void __critical_log_child(pid_t main_pid, pid_t main_tid, log_id_t log_id, int prio, const char *tag, const char *fmt, va_list ap)
537 char buf[LOG_MAX_PAYLOAD_SIZE + 128]; // extra space for some metadata
538 const int len = __critical_log_build_msg(buf, sizeof buf - 1, main_pid, main_tid, log_id, prio, tag, fmt, ap);
542 static const char *const path = "/usr/libexec/dlog-log-critical";
543 execl(path, path /* argv[0] convention */, buf, (char *) NULL);
546 /* Compilers are sometimes smart enough to recognize _exit's
547 * noreturn attribute, even if we wrap it with something that
548 * returns. This causes it to behave in unexpected ways, for
549 * example it can blow up the program regardless or it can
550 * optimize some conditionals out (and incorrectly enter them
551 * after the exit call fails to actually exit). This makes it
552 * unsuitable for tests. */
554 _exit(1); // not the regular `exit` so as not to trigger any `atexit` handlers prematurely
558 #ifndef UNIT_TEST // contains forks and exits, these don't work well with wrapping (see above)
559 void __critical_log(log_id_t log_id, int prio, const char *tag, const char *fmt, va_list ap)
561 /* Critical log functionality is mostly done in a separate binary
562 * to handle security correctly (else every process would have to
563 * possess the necessary privilege to write onto that file, which
564 * would be opening a fairly nasty can of worms from the security
565 * point of view). Our use of exec() is why a simple thread would
566 * not suffice and we're resorting to a fork.
568 * The double fork, much like a double barreled 12 gauge shotgun,
569 * is an elegant solution designed to stop a zombie army. We'd be
570 * creating zombie processes if we didn't wait() for the children
571 * we spawn, but we don't really want to do that since it results
572 * in a needless delay. Instead, the writer process is actually a
573 * grandchild, with our direct child exiting immediately just for
574 * us to have something to wait on that is guaranteed not to take
575 * too long. The orphaned grandchild is adopted by init, who will
576 * take care to reap it when it dies. In addition to avoiding the
577 * delay, the client will not have any unexpected children (which
578 * could ruin logic in its own waits).
581 * ┌───────┐ ┌─────────┐ ┌─────────────┐ ┌────────┐
582 * │ pid 1 ├──>│ libdlog ├──>│ immediately ├──>│ execs │
583 * │ init │ │ client │ │ exits │ │ writer │
584 * └───────┘ └─────────┘ └─────────────┘ └────────┘
586 * Afterwards, libdlog has no children:
587 * ┌───────┐ ┌─────────┐ ┌────────┐
588 * │ pid 1 ├──>│ libdlog │ ┌─────────>│ writer │
589 * │ init ├─┐ │ client │ │ │ binary │
590 * └───────┘ │ └─────────┘ │ └────────┘
591 * └──────────────────────┘
596 if (!enable_critical)
599 const pid_t main_pid = getpid();
600 const pid_t main_tid = gettid();
602 const int temporary_exiter_pid = fork();
603 if (temporary_exiter_pid < 0)
605 if (temporary_exiter_pid != 0) {
606 waitpid(temporary_exiter_pid, NULL, 0);
610 const int child_pid = fork();
616 __critical_log_child(main_pid, main_tid, log_id, prio, tag, fmt, ap);
619 static void stash_critical_inner(log_id_t log_id, log_priority prio, const char *tag, const char *fmt, ...)
624 __critical_log(log_id, prio, tag, fmt, ap);
628 static int stash_critical(log_id_t log_id, log_priority prio, const char *tag, const char *msg)
630 stash_critical_inner(log_id, prio, tag, "FAILED TO LOG: %s", msg);
634 EXPORT_API int __dlog_critical_print(log_id_t log_id, int prio, const char *tag, const char *fmt, ...)
639 __critical_log(log_id, prio, tag, fmt, ap);
643 int ret = __dlog_vprint(log_id, prio, tag, fmt, ap);
650 EXPORT_API int dlog_set_minimum_priority(int priority)
652 if (priority < DLOG_DEFAULT || priority > DLOG_PRIO_MAX)
653 return DLOG_ERROR_INVALID_PARAMETER;
655 priority_filter_level = priority;
656 return DLOG_ERROR_NONE;
661 * @details Print a log line
662 * @param[in] log_id The target buffer ID
663 * @param[in] prio Priority
665 * @param[in] fmt Format (same as printf)
666 * @param[in] ap Argument list
667 * @return Bytes written, or negative error
669 EXPORT_API int __dlog_vprint(log_id_t log_id, int prio, const char *tag, const char *fmt, va_list ap)
671 int ret = __write_to_log(log_id, prio, tag, fmt, ap, true, false);
672 __dlog_fatal_assert(prio);
679 * @details Print a log line
680 * @param[in] log_id The target buffer ID
681 * @param[in] prio Priority
683 * @param[in] fmt Format (same as printf)
684 * @return Bytes written, or negative error
686 EXPORT_API int __dlog_print(log_id_t log_id, int prio, const char *tag, const char *fmt, ...)
691 int ret = __dlog_vprint(log_id, prio, tag, fmt, ap);
699 * @details Print a log line
700 * @param[in] log_id The target buffer ID
701 * @param[in] prio Priority
703 * @param[in] fmt Format (same as printf)
704 * @return Bytes written, or negative error
706 EXPORT_API int __dlog_sec_print(log_id_t log_id, int prio, const char *tag, const char *fmt, ...)
708 if (!enable_secure_logs)
714 int ret = __write_to_log(log_id, prio, tag, fmt, ap, true, true);
715 __dlog_fatal_assert(prio);
721 EXPORT_API int dlog_vprint(log_priority prio, const char *tag, const char *fmt, va_list ap)
723 return __write_to_log(LOG_ID_APPS, prio, tag, fmt, ap, false, false);
726 EXPORT_API int dlog_print(log_priority prio, const char *tag, const char *fmt, ...)
731 int ret = dlog_vprint(prio, tag, fmt, ap);
738 * @brief Finalize DLog
739 * @details Finalizes and deallocates the library
740 * @notes Used directly in tests; brings back the pre-init state
742 void __dlog_fini(void)
744 if (destroy_backend) {
746 destroy_backend = NULL;
749 is_initialized = false;
752 enable_secure_logs = true;
753 enable_critical = false;
754 __deduplicate_destroy();
755 __log_limiter_destroy(limiter_data);
757 __dynamic_config_destroy();