/
niceSOFT
/
tdnf
Обзор
Документация
Войти
/
niceSOFT
/
tdnf
Код
Задачи
Вики
Пакеты
0
Релизы
0
Аналитика
Безопасность
dev
common/log.c
89 строк
1 KB
Shreenidhi Shedi
Harden TDNF build by enforcing various GCC build flags
19 сен 2025, 06:41
19 сен 2025, 06:41
2457ea6
Код
Авторство
О чём код?
/* * Copyright (C) 2019-2023 VMware, Inc. All Rights Reserved. * * Licensed under the GNU Lesser General Public License v2.1 (the "License"); * you may not use this file except in compliance with the License. The terms * of the License are located in the COPYING file of this distribution. */ #include "includes.h" static bool isQuiet = false; static bool isJson = false; static bool isDnfCheckUpdateCompat = false; void GlobalSetQuiet(int32_t val) { if (val > 0) { isQuiet = true; } } void GlobalSetJson(int32_t val) { if (val > 0) { isJson = true; } } void GlobalSetDnfCheckUpdateCompat(int32_t val) { if (val > 0) { isDnfCheckUpdateCompat = true; } } bool GlobalGetDnfCheckUpdateCompat(void) { return isDnfCheckUpdateCompat; } void log_console(int32_t loglevel, const char *format, ...) { va_list args; FILE *stream = NULL; if (!format) { return; } va_start(args, format); switch (loglevel) { case LOG_INFO: case LOG_CRIT: if (isJson) { goto end; } if (loglevel == LOG_INFO && isQuiet) { goto end; } stream = stdout; break; case LOG_ERR: stream = stderr; break; default: goto end; } if (!stream) { /* just in case */ goto end; } vfprintf(stream, format, args); fflush(stream); end: va_end(args); }