blob: 5463a2a64144b7cde5b5ab6bc82af50d3b34dbeb [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 *
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions
10 * are met:
11 * 1. Redistributions of source code must retain the above copyright
12 * notice, this list of conditions and the following disclaimer.
13 * 2. Redistributions in binary form must reproduce the above copyright
14 * notice, this list of conditions and the following disclaimer in
15 * the documentation and/or other materials provided with the
16 * distribution.
17 * 3. Neither the name of the Company nor the names of its contributors
18 * may be used to endorse or promote products derived from this
19 * software without specific prior written permission.
20 *
21 */
22
23#ifndef NC_LOG_PRIVATE_H_
24#define NC_LOG_PRIVATE_H_
25
Radek Krejcia3528022015-09-02 13:46:38 +020026#include <stdint.h>
27
28#include "log.h"
29
Radek Krejci5fe60cc2015-09-01 17:14:39 +020030/*
31 * libnetconf's message printing
32 */
33
34/**
35 * @brief internal printing function
36 * @param[in] level Verbose level
37 * @param[in] format Formatting string
38 */
39void prv_printf(NC_VERB_LEVEL level, const char *format, ...);
40
41/**
42 * @brief Verbose level variable
43 */
44extern volatile uint8_t verbose_level;
45
46/*
47 * Verbose printing macros
48 */
49#define ERR(format,args...) prv_printf(NC_VERB_ERROR,format,##args)
50#define WRN(format,args...) if(verbose_level>=NC_VERB_WARNING){prv_printf(NC_VERB_WARNING,format,##args);}
51#define VRB(format,args...) if(verbose_level>=NC_VERB_VERBOSE){prv_printf(NC_VERB_VERBOSE,format,##args);}
52#define DBG(format,args...) if(verbose_level>=NC_VERB_DEBUG){prv_printf(NC_VERB_DEBUG,format,##args);}
53
Michal Vasko9e036d52016-01-08 10:49:26 +010054#define ERRMEM ERR("%s: memory reallocation failed (%s:%d).", __func__, __FILE__, __LINE__)
Michal Vasko7f1c78b2016-01-19 09:52:14 +010055#define ERRARG ERR("%s: invalid arguments or libnetconf2 not initialized.", __func__)
Michal Vasko9e036d52016-01-08 10:49:26 +010056#define ERRINT ERR("%s: internal error (%s:%d).", __func__, __FILE__, __LINE__)
Radek Krejci52b37022015-10-06 16:11:48 +020057
Radek Krejci5fe60cc2015-09-01 17:14:39 +020058#endif /* NC_LOG_PRIVATE_H_ */