blob: d3afc4ae7a12f5200a807033353dd4a7f2916379 [file] [log] [blame]
Radek Krejci5fe60cc2015-09-01 17:14:39 +02001/**
2 * \file log.h
3 * \author Radek Krejci <rkrejci@cesnet.cz>
4 * \brief libnetconf2 logger
5 *
6 * Copyright (c) 2015 CESNET, z.s.p.o.
7 *
Radek Krejci9b81f5b2016-02-24 13:14:49 +01008 * This source code is licensed under BSD 3-Clause License (the "License").
9 * You may not use this file except in compliance with the License.
10 * You may obtain a copy of the License at
Michal Vaskoafd416b2016-02-25 14:51:46 +010011 *
Radek Krejci9b81f5b2016-02-24 13:14:49 +010012 * https://opensource.org/licenses/BSD-3-Clause
Radek Krejci5fe60cc2015-09-01 17:14:39 +020013 */
14
15#ifndef NC_LOG_PRIVATE_H_
16#define NC_LOG_PRIVATE_H_
17
Radek Krejcia3528022015-09-02 13:46:38 +020018#include <stdint.h>
19
20#include "log.h"
21
Radek Krejci5fe60cc2015-09-01 17:14:39 +020022/*
23 * libnetconf's message printing
24 */
25
26/**
Michal Vasko05532772021-06-03 12:12:38 +020027 * @brief Internal printing function
28 *
29 * @param[in] session Optional NETCONF session that generated the message
Radek Krejci5fe60cc2015-09-01 17:14:39 +020030 * @param[in] level Verbose level
31 * @param[in] format Formatting string
32 */
Michal Vasko05532772021-06-03 12:12:38 +020033void prv_printf(const struct nc_session *session, NC_VERB_LEVEL level, const char *format, ...);
Radek Krejci5fe60cc2015-09-01 17:14:39 +020034
35/**
36 * @brief Verbose level variable
37 */
38extern volatile uint8_t verbose_level;
39
40/*
41 * Verbose printing macros
42 */
Michal Vasko05532772021-06-03 12:12:38 +020043#define ERR(session, format, args ...) prv_printf(session,NC_VERB_ERROR,format,##args)
44#define WRN(session, format, args ...) if(verbose_level>=NC_VERB_WARNING){prv_printf(session,NC_VERB_WARNING,format,##args);}
45#define VRB(session, format, args ...) if(verbose_level>=NC_VERB_VERBOSE){prv_printf(session,NC_VERB_VERBOSE,format,##args);}
46#define DBG(session, format, args ...) if(verbose_level>=NC_VERB_DEBUG){prv_printf(session,NC_VERB_DEBUG,format,##args);}
47#define DBL(session, format, args ...) if(verbose_level>=NC_VERB_DEBUG_LOWLVL){prv_printf(session,NC_VERB_DEBUG_LOWLVL,format,##args);}
Radek Krejci5fe60cc2015-09-01 17:14:39 +020048
Michal Vasko05532772021-06-03 12:12:38 +020049#define ERRMEM ERR(NULL, "%s: memory reallocation failed (%s:%d).", __func__, __FILE__, __LINE__)
50#define ERRARG(arg) ERR(NULL, "%s: invalid argument (%s).", __func__, arg)
51#define ERRINIT ERR(NULL, "%s: libnetconf2 not initialized.", __func__)
52#define ERRINT ERR(NULL, "%s: internal error (%s:%d).", __func__, __FILE__, __LINE__)
Radek Krejci52b37022015-10-06 16:11:48 +020053
Radek Krejci5fe60cc2015-09-01 17:14:39 +020054#endif /* NC_LOG_PRIVATE_H_ */