]> git.ipfire.org Git - thirdparty/kmod.git/blame - libabc/libabc-private.h
Import skeleton from libabc
[thirdparty/kmod.git] / libabc / libabc-private.h
CommitLineData
ecd40ee4
LDM
1/*
2 libabc - something with abc
3
4 Copyright (C) 2011 Someone <someone@example.com>
5
6 This library is free software; you can redistribute it and/or
7 modify it under the terms of the GNU Lesser General Public
8 License as published by the Free Software Foundation; either
9 version 2.1 of the License, or (at your option) any later version.
10
11 This library is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 Lesser General Public License for more details.ΒΆ
15
16 You should have received a copy of the GNU Lesser General Public
17 License along with this library; if not, write to the Free Software
18 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
19*/
20
21#ifndef _LIBABC_PRIVATE_H_
22#define _LIBABC_PRIVATE_H_
23
24#include <stdbool.h>
25#include <syslog.h>
26
27#include "libabc.h"
28
29static inline void __attribute__((always_inline, format(printf, 2, 3)))
30abc_log_null(struct abc_ctx *ctx, const char *format, ...) {}
31
32#define abc_log_cond(ctx, prio, arg...) \
33 do { \
34 if (abc_get_log_priority(ctx) >= prio) \
35 abc_log(ctx, prio, __FILE__, __LINE__, __FUNCTION__, ## arg); \
36 } while (0)
37
38#ifdef ENABLE_LOGGING
39# ifdef ENABLE_DEBUG
40# define dbg(ctx, arg...) abc_log_cond(ctx, LOG_DEBUG, ## arg)
41# else
42# define dbg(ctx, arg...) abc_log_null(ctx, ## arg)
43# endif
44# define info(ctx, arg...) abc_log_cond(ctx, LOG_INFO, ## arg)
45# define err(ctx, arg...) abc_log_cond(ctx, LOG_ERR, ## arg)
46#else
47# define dbg(ctx, arg...) abc_log_null(ctx, ## arg)
48# define info(ctx, arg...) abc_log_null(ctx, ## arg)
49# define err(ctx, arg...) abc_log_null(ctx, ## arg)
50#endif
51
52#define ABC_EXPORT __attribute__ ((visibility("default")))
53
54void abc_log(struct abc_ctx *ctx,
55 int priority, const char *file, int line, const char *fn,
56 const char *format, ...)
57 __attribute__((format(printf, 6, 7)));
58
59#endif