diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2021-07-02 20:49:35 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2021-07-02 20:49:35 +0000 |
commit | f2c543b4ccad3b9f8871d952cddf66b3b438595b (patch) | |
tree | c3c363d1cc72514221685c42a79a19b320114acc /util/log.h | |
parent | Adding debian version 1.12-8. (diff) | |
download | nvme-cli-f2c543b4ccad3b9f8871d952cddf66b3b438595b.tar.xz nvme-cli-f2c543b4ccad3b9f8871d952cddf66b3b438595b.zip |
Merging upstream version 1.14.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'util/log.h')
-rw-r--r-- | util/log.h | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/util/log.h b/util/log.h new file mode 100644 index 0000000..15107a5 --- /dev/null +++ b/util/log.h @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2021 Martin Wilck, SUSE LLC + * SPDX-License-Identifier: LGPL-2.1-or-newer + */ +#ifndef _LOG_H +#define _LOG_H + +#ifndef MAX_LOGLEVEL +# define MAX_LOGLEVEL LOG_DEBUG +#endif +#ifndef DEFAULT_LOGLEVEL +# define DEFAULT_LOGLEVEL LOG_NOTICE +#endif + +#if (LOG_FUNCNAME == 1) +#define _log_func __func__ +#else +#define _log_func NULL +#endif + +extern int log_level; +extern bool log_timestamp; +extern bool log_pid; + +void __attribute__((format(printf, 3, 4))) +__msg(int lvl, const char *func, const char *format, ...); + +#define msg(lvl, format, ...) \ + do { \ + if ((lvl) <= MAX_LOGLEVEL) \ + __msg(lvl, _log_func, format, ##__VA_ARGS__); \ + } while (0) + +#endif /* _LOG_H */ |