/
githubmirror
/
nvme-cli
Обзор
Документация
Войти
/
githubmirror
/
nvme-cli
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
master
discoverd/src/log.h
46 строк
2 KB
Martin Belanger
discoverd: rename discoverd.conf to nvme-discoverd.conf
31 июл 2026, 10:40
31 июл 2026, 10:40
3451ae6
Код
Авторство
О чём код?
/* SPDX-License-Identifier: GPL-2.0-or-later */ /* * This file is part of nvme-cli. * Copyright (c) 2026 Dell Technologies Inc. or its subsidiaries. * * Authors: Martin Belanger <martin.belanger@dell.com> */ #pragma once /* * Logging wrapper. * * Levels mirror libnvme's (ERR/WARN/INFO/DEBUG): a message is emitted when * its level is <= the configured threshold, so DEBUG turns everything on. * All output currently goes to the systemd journal; routing lives behind * this wrapper so a future change of logging backend touches only log.c. */ enum disc_log_level { DISC_LOG_ERR = 0, DISC_LOG_WARN = 1, DISC_LOG_INFO = 2, DISC_LOG_DEBUG = 3, }; #define DISC_DEFAULT_LOGLEVEL DISC_LOG_INFO /* Set the current threshold (e.g. from nvme-discoverd's config debug-level). */ void log_set_level(int level); /* * Emit one message at @level if it passes the threshold. Use the disc_* * helpers below rather than calling this directly. */ void log_msg(int level, const char *fmt, ...) __attribute__((format(printf, 2, 3))); /* * INFO and higher print the message as-is (per convention, lead with the * TID: "<tid> | <dev> - msg" — see libnvmf_tid_str()). DEBUG additionally * prepends the calling function name for call tracing ("<func>() - msg"); * __func__ keeps it from drifting out of sync. */ #define disc_err(fmt, ...) log_msg(DISC_LOG_ERR, fmt, ##__VA_ARGS__) #define disc_warn(fmt, ...) log_msg(DISC_LOG_WARN, fmt, ##__VA_ARGS__) #define disc_info(fmt, ...) log_msg(DISC_LOG_INFO, fmt, ##__VA_ARGS__) #define disc_dbg(fmt, ...) log_msg(DISC_LOG_DEBUG, "%s() - " fmt, __func__, ##__VA_ARGS__)